Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
In Office 2007 can't see chart series values unless chart unprotec Carl Charts and Charting in Excel 0 October 28th 09 03:31 AM
Selected series in chart ojv[_2_] Excel Programming 3 June 5th 09 12:52 AM
Add values to a series in a chart Marty Charts and Charting in Excel 1 March 22nd 09 12:02 PM
Extract values off a chart??? BuickGN87 Charts and Charting in Excel 3 October 6th 06 10:40 AM
Chart -- How to chart 65536 values in 1 series? kilmaley11 About this forum 0 June 8th 05 11:19 AM


All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"