Apply Macro to ALL Charts

JonesyUK

Board Regular
Joined
Oct 11, 2005
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi Please Help:

I've recorded the following Macro in Excel:

ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.ChartGroups(1).GapWidth = 0
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent1
.ForeColor.TintAndShade = 0.3399999738
.ForeColor.Brightness = 0
.BackColor.ObjectThemeColor = msoThemeColorAccent1
.BackColor.TintAndShade = 0.7649999857
.BackColor.Brightness = 0
.TwoColorGradient msoGradientHorizontal, 1
End With
Selection.Format.Shadow.Type = msoShadow24

End Sub

I need to run this macro on about 200 charts which are all on a sheet named "CHARTS"

Can you please help me to edit this macro so that it goes through all the charts and applies these formats?

Thanks!
C
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi

Try this code. Amend the code for the name of the worksheet.

Code:
Sub Test()
Dim ws As Worksheet
Dim chtO As ChartObject
 
Set ws = Worksheets("Sheet1")
 
For Each chtO In ws.ChartObjects
    With chtO.Chart
        .ChartGroups(1).GapWidth = 0
        With .SeriesCollection(1)
            With .Format.Fill
                .Visible = msoTrue
                .ForeColor.ObjectThemeColor = msoThemeColorAccent1
                .ForeColor.TintAndShade = 0.3399999738
                .ForeColor.Brightness = 0
                .BackColor.ObjectThemeColor = msoThemeColorAccent1
                .BackColor.TintAndShade = 0.7649999857
                .BackColor.Brightness = 0
                .TwoColorGradient msoGradientHorizontal, 1
            End With
            .Format.Shadow.Type = msoShadow24
        End With
    End With
Next chtO
End Sub
 
Upvote 0
Thanks ever so much, this is perfect....

It's so frustrating to need to make a small change to the charts, because it's easy for 1, but not so easy for 200!! And most of the time I can't find the applicable objects in the Object Library....

Thanks Again...
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top