Apply different color to datalabels

T

TG

I have a code that adds series to a chart.
I want to set the Datalabel.Interior.ColorIndex, but for some reason
the ClorIndex is not applyed to the DataLabel..

Any suggestion on why? Or how can i do this?

My current code includes:

With Sheets("Chart").SeriesCollection.NewSeries
.Name = Name
.XValues = XValue
.Values = YValue
.MarkerSize = 5
.ApplyDataLabels
.DataLabels.Interior.Pattern = xlSolid
.DataLabels.Interior.ColorIndex = C
.DataLabels.Border.ColorIndex = 1
.DataLabels.Font.Size = 7
.DataLabels.Position = xlCenter
.DataLabels.Orientation = 45
.DataLabels.ShowSeriesName = True
.DataLabels.ShowValue = False
End With

(where C is set to a valid value using a Select Case loop.)
 
P

Peter T

Your code works fine for me in 2003/2007, subject of course assigning a
value for C of between 1-56 or xlAutomatic/xlNone

FWIW if only using 2007/2010, although the code will work there is a new
preferred method of applying formats to interiors.

Regards,
Peter T
 
T

TG

I'm using Excel 2010, but I can't get this code to work...

Regardless, what value er set, the interior color stays as 'white'.. ;-
(

What is the correct way to set interior for excel 2010??
 
P

Peter T

Your code also works fine in 2010, but as I mentioned before only if an
appropriate value is first assigned to C (the colorindex)

If only using 2007/2010 instead you could do something like

..DataLabels.Format.Fill.ForeColor.RGB = RGB(150,150,250)
or instead of .RGB apply SchemeColor and maybe TintAndShade

Regards,
Peter T



I'm using Excel 2010, but I can't get this code to work...

Regardless, what value er set, the interior color stays as 'white'.. ;-
(

What is the correct way to set interior for excel 2010??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top