Results 1 to 4 of 4

Change color of chart based on category name

Threaded View

  1. #1
    Registered User
    Join Date
    04-11-2016
    Location
    Melbourne
    MS-Off Ver
    2013
    Posts
    18

    Change color of chart based on category name

    Hello,

    I am trying to get the chart color to change automatically based on the series name and their given color format. I have found several sources of instructions on Google but the code doesn't seem to work.

    The first result had a code as below:
    Excel 2007 and later:
    Sub ColorBySeriesName()
      Dim rPatterns As Range
      Dim iSeries As Long
      Dim rSeries As Range
    
      Set rPatterns = ActiveSheet.Range("A1:A4")
      With ActiveChart
        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
          End If
        Next
      End With
    End Sub
    Can anyone please give me some suggestions as to how to correct the code (already in the excel) and apply it to my sheet?

    Thank you!
    Attached Files Attached Files
    Last edited by Frankximus3; 08-03-2017 at 06:10 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. change chart color based on point
    By sarinky in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-27-2015, 12:45 AM
  2. Change Bar Chart Color Based on Series Name Using VBA
    By Swishmak3r in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-24-2015, 07:34 PM
  3. Changing a pivot chart column color based on the pivot table category
    By Shawne in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2014, 09:12 AM
  4. [SOLVED] Possible to change color of a bar chart based on it's value?
    By Consty1 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-13-2013, 02:17 PM
  5. How to change color of each X category Axis.
    By gohan123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2013, 09:00 AM
  6. Replies: 1
    Last Post: 06-26-2012, 10:02 AM
  7. Color Change in chart based of condition
    By KRT in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-01-2005, 08:05 AM

Tags for this Thread

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