Yard
Well-known Member
- Joined
- Nov 5, 2008
- Messages
- 1,929
Hi,
I have a simple Pivot line chart with half a dozen series.
On the maximum value data point on each series I have a data label showing the category name.
I want to format the data label to match the line, e.g. Series1 has a red line (from the standard Excel design/style) and I want to format my data label with a red border and red text. The same will be done to the remaining series.
I can not understand how to translate the colour properties of the line into the colour properties of the text & outline of the data label.
I have this:
but it changes all the datalabel text and outlines to white. Debugging it shows that it's returning the RGB value of 16777215 for
Would appreciate any guidance.
Thanks
I have a simple Pivot line chart with half a dozen series.
On the maximum value data point on each series I have a data label showing the category name.
I want to format the data label to match the line, e.g. Series1 has a red line (from the standard Excel design/style) and I want to format my data label with a red border and red text. The same will be done to the remaining series.
I can not understand how to translate the colour properties of the line into the colour properties of the text & outline of the data label.
I have this:
Code:
Sub FormatDataLabelsLikeLine(cht As Chart)
Dim dataP As Point, dataPs As Points
Dim dataL As DataLabel
Dim Ser As Series
For Each Ser In cht.SeriesCollection
Set dataPs = Ser.Points
For Each dataP In dataPs
If dataP.HasDataLabel Then
Set dataL = dataP.DataLabel
With dataL.Format.TextFrame2.TextRange.Font.Fill
.Visible = msoTrue
.ForeColor.RGB = Ser.Format.Line.ForeColor.RGB
.Solid
End With
With dataL.Format.Line
.Visible = msoTrue
.ForeColor.RGB = Ser.Format.Line.ForeColor.RGB
End With
End If
Next dataP
Next Ser
End Sub
but it changes all the datalabel text and outlines to white. Debugging it shows that it's returning the RGB value of 16777215 for
Code:
Ser.Format.Line.ForeColor.RGB
Would appreciate any guidance.
Thanks