Results 1 to 7 of 7

Matching 'Chart Series title' to equation driven cells to set the series line colour

Threaded View

  1. #1
    Registered User
    Join Date
    11-12-2018
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2016 (Office 365 ProPlus)
    Posts
    58

    Lightbulb Matching 'Chart Series title' to equation driven cells to set the series line colour

    I am struggling to get the below code to find a match between the Chart Series name & a selected Range cell text, but only when both are driven by equations. If no equations are used (and text only is used in the colour cells) it works fine. Any ideas why this may be the case?

    Sub ColorBySeriesName()
      Dim rPatterns As Range
      Dim iSeries As Long
      Dim rSeries As Range
      
      
      Set rPatterns = Worksheets("Chart").ListObjects("ColorBySeriesName").DataBodyRange
      
      With ActiveSheet.ChartObjects("Chart1").Chart
        For iSeries = 1 To .SeriesCollection.Count
          Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Name, _
              LookAt:=xlWhole)
          If Not rSeries Is Nothing Then
            .SeriesCollection(iSeries).Format.Fill.ForeColor.RGB = _
                rSeries.Interior.Color
            .SeriesCollection(iSeries).Format.Line.ForeColor.RGB = _
                rSeries.Interior.Color
          End If
        Next
      End With
    End Sub
    Also attaching a simplified worksheet to illustrate the problem. If you click the 'Refresh' button above the chart on the second worksheet then nothing happens. But replace the equations in the Colour table with plain text (A, B, C etc...) then hit refresh and all will work just fine!! Thanks for any help!
    Attached Files Attached Files
    Last edited by mattydboom1; 02-14-2020 at 03:25 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA for recolouring all series in a chart the same colour
    By HanJam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2019, 07:15 AM
  2. [SOLVED] VBA - Search Chart for Data Series Title and format.
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-24-2017, 09:16 AM
  3. Change colour of chart series with VBA
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-17-2017, 10:06 PM
  4. Chart Series Automatic Colour
    By AndersonM in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-01-2016, 06:37 AM
  5. [SOLVED] Change series line colour to match marker colours
    By sweep in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-15-2014, 03:04 AM
  6. [SOLVED] Align Line Chart's data series Data labels on top of Bar chart data series
    By rgunlimited in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2014, 10:38 AM
  7. Change colour of chart series
    By downunderthunder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2010, 09:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1