Pie Chart Comparison [Solved/Closed]

- - Latest reply: TrowaD
Posts
2566
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 19, 2019
- Mar 18, 2011 at 11:44 AM
Hello,

I have made a number of different pie charts & want to compare them with each other. Each pie chart is comparing the same thing but the sections in the chart show up in a different colour on each different chart. Is there a way to syncronize the colours through all the pie's so they are more easily comparable, ie, Client A = blue, Client B = green, etc?

Thanks,

Rach


See more 

1 reply

Posts
2566
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 19, 2019
370
0
Thank you
Hi Rachel,

You could record a macro. Select one chart adjust the colors of all the fields. then select every other chart. Stop recording and look at the code.
Now copy the lines of code below your first chart and paste them underneath all the other charts.

I did this for two pie charts. the code looks like this:
Sub Macro1() 
' 
' Macro1 Macro 
' De macro is opgenomen op 18-3-2011 door Trowa. 
' 

' 
    ActiveSheet.ChartObjects("Grafiek 1").Activate 
    ActiveChart.SeriesCollection(1).Select 
    ActiveChart.SeriesCollection(1).Points(3).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 45 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(2).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 3 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(1).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 32 
        .Pattern = xlSolid 
    End With 
    ActiveWindow.Visible = False     
Windows("Map1").Activate 
    ActiveSheet.ChartObjects("Grafiek 2").Activate 
    ActiveChart.SeriesCollection(1).Select 
    ActiveChart.SeriesCollection(1).Points(3).Select 
End Sub


I then copied the bold part and pasted it below the Italic line to make it look like this:
Sub test() 

ActiveSheet.ChartObjects("Grafiek 1").Activate 
    ActiveChart.SeriesCollection(1).Select 
    ActiveChart.SeriesCollection(1).Points(3).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 45 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(2).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 3 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(1).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 32 
        .Pattern = xlSolid 
    End With 
    ActiveWindow.Visible = False 
    Windows("Map1").Activate 
    ActiveSheet.ChartObjects("Grafiek 2").Activate 
    ActiveChart.SeriesCollection(1).Select 
    ActiveChart.SeriesCollection(1).Points(3).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 45 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(2).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 3 
        .Pattern = xlSolid 
    End With 
    ActiveChart.SeriesCollection(1).Points(1).Select 
    With Selection.Border 
        .Weight = xlThin 
        .LineStyle = xlAutomatic 
    End With 
    Selection.Shadow = False 
    With Selection.Interior 
        .ColorIndex = 32 
        .Pattern = xlSolid 
    End With 
    ActiveWindow.Visible = False 
End Sub


Then run the code and both charts look the same color wise.

Best regards,
Trowa