Zohra has attended:
Excel Advanced course
Excel Intermediate course
Excel VBA Intro Intermediate course
VBA Pivot Chart Colours
Is there VB code I can write to change the colour of series on a pivot chart?
Further to that, can I then create a loop to run through however many series I have, so that I can change the colours without hard coding how many series I have?
RE: VBA Pivot Chart Colours
Hello Zohra
Thank you for your question
The answer to your question is essentially yes.
You can alter the colour of a series simply by altering the colorIndex property of the series's interior
Typically, this might look something like:-
With Selection.Interior
.ColorIndex = 3
End With
In terms of cycling through series, again this is simple enough. Individual series in a chart are series objects, and belong to the SeriesCollection. This means that it is possible to cycle through each series by using a "For Each Object in SeriesCollection" structure.
If you require further help, could you email a sample chart and worksheet as the details will depensd on the type of chart and data. If this is possible please email it to
infoATmicrosofttrainingDOTnet and mark it for the attention of stephen
Regards
Stephen