+ Reply to Thread
Results 1 to 2 of 2

VBA - changing colour of all graphs

  1. #1
    Registered User
    Join Date
    10-04-2018
    Location
    London
    MS-Off Ver
    MS13
    Posts
    1

    VBA - changing colour of all graphs

    Hello I'm trying to make a loop to edit all the graphs in a workbook. There's a variety of charts with 1, 2, 3 or 4 bars. I want to go through and make all the 1st bars one colour, 2nd bars another etc. I've tried to make a loop (very new to VBA), below, but it fails whenever it gets to a chart with less than 4 bars because it says the 'parameter is not valid'.

    How do I edit the below to ignore the FullSeriesCollections is they are not present in the active chart?

    Sub ColourChange()

    Dim sht As Worksheet
    Dim CurrentSheet As Worksheet
    Dim cht As ChartObject

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Set CurrentSheet = ActiveSheet

    For Each sht In ActiveWorkbook.Worksheets
    For Each cht In sht.ChartObjects
    cht.Activate

    ActiveChart.FullSeriesCollection(1).Select
    With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(0, 176, 80)
    .Transparency = 0
    .Solid
    End With
    ActiveChart.FullSeriesCollection(2).Select
    With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.Brightness = RGB(192, 192, 0)
    .Transparency = 0
    .Solid
    End With
    ActiveChart.FullSeriesCollection(3).Select
    With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(192, 0, 0)
    .Transparency = 0
    .Solid
    End With
    ActiveChart.FullSeriesCollection(4).Select
    With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(192, 0, 192)
    .Transparency = 0
    .Solid
    End With

    Next cht
    Next sht

    CurrentSheet.Activate
    Application.EnableEvents = True

    End Sub

    Thanks

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA - changing colour of all graphs

    One of the variants, but this is not a modification of your macro ... :
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 11
    Last Post: 01-16-2018, 09:03 AM
  2. Changing chart colour to reflect colour of cell
    By hillwalker11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-13-2016, 03:12 AM
  3. Need way of changing graph line colour for multiple graphs
    By hunterage2000 in forum Excel General
    Replies: 2
    Last Post: 01-30-2016, 06:22 AM
  4. Replies: 3
    Last Post: 02-13-2014, 06:31 AM
  5. Excel 2007 : Text in graphs changing colour randomly
    By aquitaine137 in forum Excel General
    Replies: 1
    Last Post: 06-12-2012, 05:18 AM
  6. changing all text boxes of one fill colour to another colour
    By was0696 in forum Word Formatting & General
    Replies: 3
    Last Post: 02-18-2010, 05:57 AM
  7. [SOLVED] How do I save new colour schemes for graphs in the colour template
    By Alison in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-22-2006, 05:40 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