Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
feh feh is offline
external usenet poster
 
Posts: 3
Default trouble setting colors

I'd like to set the color of the datalabels for my series to be the
same as the series itself.

The following does not work. It would seem that the color codes used
by .interior.color of the series are different from those used for the
font of a selection of a datalabel.

Dim myChrt As Chart
Set myChrt = ActiveChart
Dim oSer As Series
Dim dlabel As DataLabel
Dim oSerColor As String

For Each oSer In myChrt.SeriesCollection

oSerColor = oSer.Interior.Color

oSer.HasDataLabels = True
For Each dlabel In oSer.DataLabels
dlabel.Select
Selection.Font.Color = oSerColor
Next

Next


I'm using office 2007 btw.

Thanks,
Charles
  #2   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default trouble setting colors

It worked for me in xl2003.



"feh" wrote in message
...
I'd like to set the color of the datalabels for my series to be the
same as the series itself.

The following does not work. It would seem that the color codes used
by .interior.color of the series are different from those used for the
font of a selection of a datalabel.

Dim myChrt As Chart
Set myChrt = ActiveChart
Dim oSer As Series
Dim dlabel As DataLabel
Dim oSerColor As String

For Each oSer In myChrt.SeriesCollection

oSerColor = oSer.Interior.Color

oSer.HasDataLabels = True
For Each dlabel In oSer.DataLabels
dlabel.Select
Selection.Font.Color = oSerColor
Next

Next


I'm using office 2007 btw.

Thanks,
Charles



  #3   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default trouble setting colors

Hi Charles,

Following appears to work in xl2007.

Note: oSerColor As Long not string

Dim myChrt As Chart
Set myChrt = ActiveChart
Dim oSer As Series
Dim dlabel As DataLabel
Dim oSerColor As Long

For Each oSer In myChrt.SeriesCollection
oSerColor = oSer.Border.Color
oSer.HasDataLabels = True
For Each dlabel In oSer.DataLabels
dlabel.Font.Color = oSerColor
Next dlabel
Next oSer

--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default trouble setting colors

Hi again Charles,

Just a little added info. In lieu of activating the chart and then setting a
variable to the active chart you can use the following line of code and there
is no need to activate the chart.

Set myChrt = ActiveSheet.ChartObjects("Chart 3").Chart

or

Set myChrt = Sheets("Sheet1").ChartObjects("Chart 3").Chart


If you don't know the name of the chart.
Select any cell on the worksheet (to deactivate the chart)
Turn on the macro recorder.
Select the chart.
Turn off the macro recorder
You should have a recorde line of code like the following.

ActiveSheet.ChartObjects("Chart 3").Activate

--
Regards,

OssieMac

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
Dynamically setting worksheet tab colors John Excel Worksheet Functions 4 January 29th 09 06:55 PM
MY 2003 Excel does not show cell colors. Solution? Setting? WetRiverOak Excel Discussion (Misc queries) 1 August 2nd 06 04:21 AM
Setting colors of results in a column ERBERB Excel Discussion (Misc queries) 1 October 28th 05 01:21 PM
having trouble setting page breaks on excel- have ms 2000 Jen Excel Discussion (Misc queries) 0 April 20th 05 02:29 PM
Trouble setting total for on chart Mark Charts and Charting in Excel 1 January 11th 05 02:21 AM


All times are GMT +1. The time now is 04:34 PM.

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"