How do you select a chart data label by its name to format it?
This code by BigBen uses .Caption
to select a certain label and rename it:
Loop through chart and altering labels (Category Name)
Sub ShortenLabels()
Dim k As Long, j As Long
With ActiveChart
For k = 1 To .SeriesCollection.Count
For j = 1 To .SeriesCollection(k).Points.Count
With .SeriesCollection(k).Points(j).DataLabel
.Caption = Replace(.Caption, "AAAA", "AA")
.Caption = Replace(.Caption, "BBBB", "BB")
.Caption = Replace(.Caption, "CCCC", "CC")
End With
Next j
Next k
End With
End Sub
How do you say, “with label with .Caption
= “AA”, e.g. change font color?
Sub FormatLabelWithCertainCaption()
Dim k As Long, j As Long
With ActiveChart
For k = 1 To .SeriesCollection.Count
For j = 1 To .SeriesCollection(k).Points.Count
With .SeriesCollection(k).Points(j).DataLabel
With .Caption = "AA"
' change font color
End With
End With
Next j
Next k
End With
End Sub