View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default check for alphabet in datalabel and then superscript that letter

J,
See how this works for you.
Jim Cone
San Francisco, USA

'---------------------------------------
Sub Superscripting()
Dim blnOK As Boolean
Dim N As Long
Dim x As Long
Dim y As Long
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowLabel, LegendKey:=False

For x = 1 To ActiveChart.SeriesCollection.Count
With ActiveChart.SeriesCollection(x)
For y = 1 To .Points.Count
If .Points(y).HasDataLabel Then
For N = 1 To Len(.Points(y).DataLabel.Text)
'If any alpha character then ok to format.
If Not Mid$(.Points(y).DataLabel.Text, N, 1) Like "#" Then
blnOK = True
Exit For
End If
Next 'N
'Make sure there are three characters.
If blnOK And Len(.Points(y).DataLabel.Text) 2 Then _
.Points(y).DataLabel.Characters(3, 1).Font.Superscript = True
End If
blnOK = False
Next y
End With
Next x
End Sub
'---------------------------------


"Jyotsna"
wrote in message
...
Hi all,
I have a macro where the macro checks for the presence of datalabel and the
superscripts the 3rd character. so far this works fine, here is the code
below.

Sub Superscripting()
Dim x As Integer, y As Integer
Dim Ix As Integer
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowLabel, LegendKey:=False
ActiveChart.SeriesCollection(1).DataLabels.Select
'ActiveChart.SeriesCollection(1).Points(2).DataLab el.Select

For x = 1 To ActiveChart.SeriesCollection.Count
For y = 1 To ActiveChart.SeriesCollection(x).Points.Count
With ActiveChart.SeriesCollection(x)
If .Points(y).HasDataLabel Then
.Points(y).DataLabel.Characters(3, 1).Font.Superscript = True
End If
End With
Next y
Next x
End Sub

Now what i want to do is to determine if the datalabel has alphabet and
numbers, if only numbers then do nothing, but if it has alphabets as well
then superscript the alphabet part of the datalabel.
Hope some one could help me
Thanks a many.
Jyotsna