Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extract RGB values for selected chart series
In EXCEL 2007:
I create a pie chart using Insert Charts. The chart is created using the default MS Office Theme. If I then select an individual pie slice and Format data point the 'Fill' is set to Automatic. When I select 'Solid fill' to try and get the RGB values for that pie slice the color changes to a different color! I'm trying to set up a macro to select a data series and extract the RGB values for that data series. The RGB values would then appear in a message box. Thanks. Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extract RGB values for selected chart series
Crude, but it seems to work:
Sub Pie_Chart_Wedge_Color() If ((ActiveChart.ChartType = xlPie Or _ ActiveChart.ChartType = xlPieExploded Or _ ActiveChart.ChartType = xlPieOfPie Or _ ActiveChart.ChartType = xl3DPie Or _ ActiveChart.ChartType = xl3DPieExploded) And _ TypeName(Selection) = "Point") Then MsgBox "The chart you selected is: " & ActiveChart.Name & Chr(10) & Chr(10) & _ "The wedge color is RGB(" & Selection.Fill.ForeColor.RGB Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256) Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256 \ 256) Mod 256 & ")" Else MsgBox "You must have a single wedge of a pie chart selected!" End If End Sub Note that a pie chart has only one series, so you have to refer to individual points in the series to get the color of each wedge. Select a pie chart, then select an individual wedge in the chart, and run this routine. HTH, Eric "MikeM_work" wrote: In EXCEL 2007: I create a pie chart using Insert Charts. The chart is created using the default MS Office Theme. If I then select an individual pie slice and Format data point the 'Fill' is set to Automatic. When I select 'Solid fill' to try and get the RGB values for that pie slice the color changes to a different color! I'm trying to set up a macro to select a data series and extract the RGB values for that data series. The RGB values would then appear in a message box. Thanks. Mike |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extract RGB values for selected chart series
Eric:
Thanks a lot; this is great! This had been a vexing problem as we have some color blind users who need RGB values. It's curious that it seems the only way to do this is with some VBA. (Perhaps I'm wrong about that but I can't seem to do that simple task). I simplified it a bit (I don't need any error trapping). Now I can use it on any series for any chart type (or individual data point in a pie chart): Sub RGB_Color() MsgBox "The chart you selected is: " & ActiveChart.Name & Chr(10) & Chr(10) & _ "The color is RGB (" & Selection.Fill.ForeColor.RGB Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256) Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256 \ 256) Mod 256 & ")" End Sub Thanks! Mike "EricG" wrote: Crude, but it seems to work: Sub Pie_Chart_Wedge_Color() If ((ActiveChart.ChartType = xlPie Or _ ActiveChart.ChartType = xlPieExploded Or _ ActiveChart.ChartType = xlPieOfPie Or _ ActiveChart.ChartType = xl3DPie Or _ ActiveChart.ChartType = xl3DPieExploded) And _ TypeName(Selection) = "Point") Then MsgBox "The chart you selected is: " & ActiveChart.Name & Chr(10) & Chr(10) & _ "The wedge color is RGB(" & Selection.Fill.ForeColor.RGB Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256) Mod 256 & ", " & _ (Selection.Fill.ForeColor.RGB \ 256 \ 256) Mod 256 & ")" Else MsgBox "You must have a single wedge of a pie chart selected!" End If End Sub Note that a pie chart has only one series, so you have to refer to individual points in the series to get the color of each wedge. Select a pie chart, then select an individual wedge in the chart, and run this routine. HTH, Eric "MikeM_work" wrote: In EXCEL 2007: I create a pie chart using Insert Charts. The chart is created using the default MS Office Theme. If I then select an individual pie slice and Format data point the 'Fill' is set to Automatic. When I select 'Solid fill' to try and get the RGB values for that pie slice the color changes to a different color! I'm trying to set up a macro to select a data series and extract the RGB values for that data series. The RGB values would then appear in a message box. Thanks. Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
In Office 2007 can't see chart series values unless chart unprotec | Charts and Charting in Excel | |||
Selected series in chart | Excel Programming | |||
Add values to a series in a chart | Charts and Charting in Excel | |||
Extract values off a chart??? | Charts and Charting in Excel | |||
Chart -- How to chart 65536 values in 1 series? | About this forum |