Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colors on a pie chart
Hi guys,
I am trying to create a macro to re-colour a selection of pie charts with standard colours. They all have a different number of points but I want the same colour sequence for each chart. For example: ActiveChart.SeriesCollection(1).Points(1).Interior .ColorIndex = 55 ActiveChart.SeriesCollection(1).Points(2).Interior .ColorIndex = 47 etc... However, I don't know how to do it for the variable number of points. Any suggestions? Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colors on a pie chart
Sub PrettyPie()
Dim n As Long Dim arr Dim cht As Chart Dim sr As Series Dim pt As Point ' fill this array with at least as many colorindex's ' as any potential qty of points arr = Array(55, 47, 11, 5, 49, 14, 51, 10, _ 52, 12) ' ensure a chart is active Set cht = ActiveChart If cht Is Nothing Then MsgBox "Select a pie chart to colour" Exit Sub End If Set sr = cht.SeriesCollection(1) For Each pt In sr.Points pt.Interior.ColorIndex = arr(n) If n = UBound(arr) Then n = 0 Else n = n + 1 End If Next End Sub Consider also customizing the chart colours in the bottom two rows of the extended palette, these are the default or automatic colours that are applied. Regards, Peter T "ML" wrote in message ... Hi guys, I am trying to create a macro to re-colour a selection of pie charts with standard colours. They all have a different number of points but I want the same colour sequence for each chart. For example: ActiveChart.SeriesCollection(1).Points(1).Interior .ColorIndex = 55 ActiveChart.SeriesCollection(1).Points(2).Interior .ColorIndex = 47 etc... However, I don't know how to do it for the variable number of points. Any suggestions? Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colors on a pie chart
Hi
Thanks for this. It's worked well. My pie is now pretty. ML "Peter T" wrote: Sub PrettyPie() Dim n As Long Dim arr Dim cht As Chart Dim sr As Series Dim pt As Point ' fill this array with at least as many colorindex's ' as any potential qty of points arr = Array(55, 47, 11, 5, 49, 14, 51, 10, _ 52, 12) ' ensure a chart is active Set cht = ActiveChart If cht Is Nothing Then MsgBox "Select a pie chart to colour" Exit Sub End If Set sr = cht.SeriesCollection(1) For Each pt In sr.Points pt.Interior.ColorIndex = arr(n) If n = UBound(arr) Then n = 0 Else n = n + 1 End If Next End Sub Consider also customizing the chart colours in the bottom two rows of the extended palette, these are the default or automatic colours that are applied. Regards, Peter T "ML" wrote in message ... Hi guys, I am trying to create a macro to re-colour a selection of pie charts with standard colours. They all have a different number of points but I want the same colour sequence for each chart. For example: ActiveChart.SeriesCollection(1).Points(1).Interior .ColorIndex = 55 ActiveChart.SeriesCollection(1).Points(2).Interior .ColorIndex = 47 etc... However, I don't know how to do it for the variable number of points. Any suggestions? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Chart background colors by value | Charts and Charting in Excel | |||
Chart Colors | Charts and Charting in Excel | |||
Bar Chart colors less than zero | Excel Discussion (Misc queries) | |||
Pie Chart Colors | Excel Programming | |||
static colors in chart chart | Charts and Charting in Excel |