Urgent help with a macro

J

Jyotsna

Hi all,

Yesterday I posted an question please see below the complete thread. Jim is
so close to what i really want to do. but i cannot wait, Could some one
please jump in and help me out here. Thanks.

*********************************************************
Hey Jim,

THanks for the reply. I really appriciate your efforts in helping novice
people like me... I did try the code, all it does is superscripts the 3rd
character of the datalabel even if the character is a number. May be I was
not clear of what I want. Sorry if I misled you.

But what I want to do is to check in each datalabel for an alphabet and if
there is then superscript that alphabet only. do not want to superscript the
3rd character like in the sub routine I pasted below. I found this code on
one of the posts and may be we can use that, I am not sure on how to apply
that. New to writing macros as you can see :))

If Asc(Icurrent_char) >= 48 And Asc(Icurrent_char) <= 57 Then Exit Sub
If Icurrent_char = "-" Then Exit Sub
With DataLabel.Characters(Start:=Ii, Length:=1).Font
.Superscript = True


Thanks
J
 
T

Tom Ogilvy

Think you would have to say exactly what the code isn't doing that you want
done -- what do you need help on.
 
J

Jyotsna

Ok let me try and explain again.

--The code that Jim posted as a reply actually checks for an alphabet in the
datalabel and if an alphabet is present then goes and superscript the 3rd
character in the datalabel .

-- What i actually want is, to check in each datalabel for presence of an
alphabet and if there is an alphabet present in the datalabel then
superscript that alphabet only in the datalabel and not the 3rd charecter
like in the subroutine below.

Hope this explains it. Please help me.

Thanks again
Jyotsna
 
T

Tom Ogilvy

Sorry, I was looking at the text of your post and down at the code at the
bottom. I missed one of the string of emails.

this worked for me:

Sub Superscripting()
Dim blnOK As Boolean
Dim N As Long
Dim x As Long
Dim y As Long
Dim ipt As Long
Dim ilen 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
blnOK = False
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
If Not blnOK Then
ipt = N
ilen = 1
blnOK = True
Else
ilen = ilen + 1
End If
ElseIf blnOK Then
Exit For
End If
Next 'N
'Make sure there are three characters.
If blnOK And Len(.Points(y).DataLabel.Text) > 0 Then _
.Points(y).DataLabel.Characters(ipt,
ilen).Font.Superscript = True
End If
Next y
End With
Next x
End Sub
 
J

Jyotsna

Thank you soooo much for this. Worked like a charm.

You can add me to your fan list now :))

Jyotsna
 
J

Jyotsna

I agree. Thanks Jim Cone. I am your fan as well. ;)) will actually thank him
by replying to previous thread as well.

Now as I am working with this code. I reasize that the superscripting
happens to the first occurence of a letter in the datalabel. Meaning if a
series of datalabels like 23a45b and 23c45d is there then only "a" and "c"
from the respective datalabel gets superscripted. It there a way to
superscript just alpahbets but all the occurence of them. Like if we still
consider the example above is it possible to superscript both "a" and "b".
Those letter can be any where in the datalabel.


Thanks
Jyotsna
 
T

Tom Ogilvy

Untested, but try this:

Sub Superscripting()
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 Not (Mid$(.Points(y).DataLabel.Text, N, 1) Like "#")
Then
.Points(y).DataLabel.Characters(N,1).Font.Superscript
= True
End if
Next 'N
Next y
End With
Next x
End Sub
 
J

Jyotsna

Works perfectly after I added -- a missing "end if" after "Next ' N" and
before "Next y"

You are toooooo good. Thanks for all you help.

One last question -- Can you direct me to discussion for programming in
powerpoint. Seems like we cannot post questions there any more.


Jyotsna
 
T

Tom Ogilvy

I am sorry - I don't know.
I would try asking in the regular power point group

microsoft.public.PowerPoint
 

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