Pie Chart Slice Colours

stephen.smith

Board Regular
Joined
Jul 7, 2010
Messages
119
Hi Guys
I need to change the slice colours in around 200 pie charts as quickly as possible. I dont want to right click on each slice in each individual slice and format the data point. Is there a quick way of doing it that anyone knows of?
Thanks in advance
Stephen
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this

Code:
Sub ChangeColorPie()

    For Each chtobj In ActiveSheet.ChartObjects
    
        ActiveSheet.chtobj("Chart 1").Activate
        
        ActiveChart.SeriesCollection(1).Points(1).Select
        With Selection.Interior
            .ColorIndex = 3
        End With
        
        ActiveChart.SeriesCollection(1).Points(2).Select
        With Selection.Interior
            .ColorIndex = 10
        End With
        
    Next chtobj

End Sub
 
Upvote 0
Thanks but this is not working. I have copied and pasted your code and then when i go to the worksheet and press run macro, it shows me an error message. Any Ideas??
 
Upvote 0
Sorry, just too quick with my answer. Try the code below.

Code:
Sub ChangeColorPie()

    For Each chtobj In ActiveSheet.ChartObjects
        
        ActiveSheet.ChartObjects(chtobj.Name).Activate
        
        ActiveChart.SeriesCollection(1).Points(1).Select
        With Selection.Interior
            .ColorIndex = 3
        End With
        
        ActiveChart.SeriesCollection(1).Points(2).Select
        With Selection.Interior
            .ColorIndex = 10
        End With
        
    Next chtobj

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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