Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
.DataLabel.Characters(2, 2).Font.Subscript = True
In the Characters property, the first value is the position of the starting character, while the second is the number of characters. Since you want two characters subscripted, the second parameter should be 2. With .SeriesCollection(3).Points(1) 'Refers to third series, first data point
With ActiveSheet.ChartObjects("Chart 1").Chart
Sub MarkerSubscript()
Dim s As String
With ActiveSheet.ChartObjects("Chart 1").Chart
With .SeriesCollection(3).Points(1)
s = Range("B2").Value
.ApplyDataLabels
.DataLabel.Text = s
.DataLabel.Characters(2, 2).Font.Subscript = True
End With
End With
End Sub
BradSub SetLabel()
Dim s As String
With ActiveSheet.ChartObjects(1).Chart
With .SeriesCollection(3).Points(1)
s = Range("N21").Value
.ApplyDataLabels
.DataLabel.Text = s
.DataLabel.Characters(1, Len(s)).Font.Subscript = False
.DataLabel.Characters(2, 2).Font.Subscript = True
End With
End With
End Sub
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Open in new window
It is worth noting that I encountered a fatal error when more than one cell in the series had a datalabel and they had different number of characters. In other words, if the numbers were subscripted in P90 and P656 there would be a problem. If the two values were P80 and P89, however, the code would work fine.Brad