Excel – How to change chart colors in VBA

excelvba

I have to change the colors of a pie chart in VBA. I 'managed' to change the font color, which is not what I wanted, this way:

ActiveChart.Legend.LegendEntries(1).Border.ColorIndex = 6

I want to change the color of the actual piece of pie.
I also have to set specific colors, which are part of the standard palette. The 6 above gives me a flashy yellow but I want the colors highlighted here

enter image description here

Best Answer

When faced with problems like this, I usually record a macro and examine what Excel does. I'd try this:

ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 6

For colors, check out the RGB(red,green,blue) function.