Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 269603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:51:47+00:00 2026-05-11T23:51:47+00:00

I want to outline the chart data range source(s) in a table, in much

  • 0

I want to outline the chart data range source(s) in a table, in much the same way that the GUI will outline a range in blue if the chart data series is clicked. The user can choose various chart views and the range highlight colours for each data series need to match those displayed in the chart.

For the record, here are the methods I considered:

  1. Parse the chart series values string and extract the data range
  2. Do a lookup on a table that stores information on the ranges and the colours to be used

In the end I went with option 2 as is seemed easier to implement and to properly manage the colours I would probably have to store them for method 1 anyway, negating its benefits.

The highlight procedure is called from the Worksheet_Change event, a lookup is done on the chart name, the ranges and colours pulled from the table and then the cell formatting is carried out. The limitation of this method is that the range/colour data for each new chart view must be pre-calculated. This isn’t much of a problem for my current implementation, but my be a limiting factor in future use where the charts might be more dynamic.

So although I’ve got a version of this working fine, I’m sure there must be a more elegant way of achieving this.

Any suggestions?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:51:47+00:00Added an answer on May 11, 2026 at 11:51 pm

    Edit:

    OK, this seems to handle more cases better. The triggering code is the same, but here is new code for the module:

    Function SeriesRange(s As Series) As Range
        Dim sf As String, fa() As String
    
    
        sf = s.Formula
        sf = Replace(sf, "=SERIES(", "")
    
        If sf = "" Then
            Set SeriesRange = Nothing
            Exit Function
        End If
    
        fa = Split(sf, ",")
    
    
        Set SeriesRange = Range(fa(2))
    
    End Function
    
    Sub x(c As Chart)
        Dim sc As Series
        Dim sr As Range
    
        If SeriesRange(c.SeriesCollection(1)) Is Nothing Then
            Exit Sub
        End If
    
        Set sr = SeriesRange(c.SeriesCollection(1))
    
        sr.CurrentRegion.Interior.ColorIndex = xlNone
        For Each sc In c.SeriesCollection
            If sc.Interior.Color > 1 Then
                SeriesRange(sc).Interior.Color = sc.Interior.Color
            ElseIf sc.Border.ColorIndex > 1 Then
                SeriesRange(sc).Interior.Color = sc.Border.Color
            ElseIf sc.MarkerBackgroundColorIndex > 1 And sc.MarkerBackgroundColorIndex < 57 Then
                SeriesRange(sc).Interior.ColorIndex = sc.MarkerBackgroundColorIndex
            ElseIf sc.MarkerForegroundColorIndex > 1 And sc.MarkerForegroundColorIndex < 57 Then
                SeriesRange(sc).Interior.ColorIndex = sc.MarkerForegroundColorIndex
            Else
                MsgBox "Unable to determine chart color for data series " & sc.Name & " ." & vbCrLf _
                        & "It may help to assign a color rather than allowing AutoColor to assign one."
            End If
        Next sc
    
    End Sub
    

    /Edit

    This is probably more barbaric than elegant, but I think it does what you want. It involves your first bullet point to get the range from the Series object, along with a sub to run through all the Series objects in the SeriesCollection for the chart. This is activated on Chart_DeActivate. Most of this code is jacked – see comments for sources.

    In a module:

    Function SeriesRange(s As Series) As Range
        Dim sf As String, fa() As String
        Dim i As Integer
        Dim result As Range
    
        sf = s.Formula
        sf = Replace(sf, "=SERIES(", "")
    
        fa = Split(sf, ",")
    
        Set SeriesRange = Range(fa(2))
    End Function
    
    Sub x(c As Chart)
        Dim sc As Series
        Dim sr As Range
    
        Set sr = SeriesRange(c.SeriesCollection(1))
    
        sr.CurrentRegion.Interior.ColorIndex = xlNone
    
        For Each sc In c.SeriesCollection
            SeriesRange(sc).Interior.Color = sc.Interior.Color
        Next sc
    
    End Sub
    

    In the ThisWorkbook object module:

    ' Jacked from C Pearson http://www.cpearson.com/excel/Events.aspx '
    Public WithEvents CHT As Chart
    
    Private Sub CHT_Deactivate()
        x CHT 
    End Sub
    
    Private Sub Workbook_Open()
        Set CHT = Worksheets(1).ChartObjects(1).Chart 
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an etag that matches what Apache produces. How does apache
Given n points on the outline of the unit circle, I want to calculate
Want to know what the stackoverflow community feels about the various free and non-free
Want my FireFox at work to be in sync with my FireFox at my
I want to loop over the contents of a text file and do a
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I want to create a Java application bundle for Mac without using Mac. According
I want to create a client side mail creator web page. I know the
I want to reference a COM DLL in a .NET project, but I also
I want to setup a cron job to rsync a remote system to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.