tags:

views:

442

answers:

1

Hi. 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 img412.imageshack.us/img412/6720/colorsh.png

Sorry for the image link, I don't have enough reputation to post images yet.

Thanks !

A: 

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.

Anders Lindahl
Great ! Changed ColorIndex to Color to be able to use RGB() :ActiveChart.SeriesCollection(1).Points(1).Interior.Color = RGB(0, 176, 80)
Gabriel
recording may not work in Excel 2007. If I remember correctly, recording chart changes resulted in nothing being recorded. (Happy to be corrected :) )
guitarthrower