Make last character in cell superscript

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,968
This is an example off MS Help. This works if the last character is alpha, but fails if it is numeric.
Can this be altered to show a number w/ a superscript number?

This example makes the last character in cell A1 a superscript character.[/size]

Code:
Sub MakeSuperscript()
    Dim n As Integer

    n = Worksheets("Sheet1").Range("A1").Characters.Count
    Worksheets("Sheet1").Range("A1").Characters(n, 1) _
    .Font.Superscript = True
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

Try,

Code:
Sub MakeSuperscript()
    Dim n As Integer

    n = Worksheets("Sheet1").Range("A1").Characters.Count
    Worksheets("Sheet1").Range("A1").NumberFormat = "@"
    Worksheets("Sheet1").Range("A1").Characters(n, 1) _
    .Font.Superscript = True
End Sub

HTH
 
Upvote 0
Hi Kris,
Sorry, but I get a Run-time error: 1004
Unable to get the count property of the characters class

this occurs on N = Worksheets("Sheet1").Range("A1").Characters.Count
 
Upvote 0
Yes Kris,
But from the error, it seems like the reference to the sheet is not the issue, but rather an issue w/ the number of characters for the count property.
But this is just a guess on my part.

thanks,

doug
 
Upvote 0
Doug

It isn't possible to superscript part of a number.
 
Upvote 0
Doug

Well if Kris has a number in A1 he'll get an error.:)

What are you actually trying to achieve?
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,227
Members
448,878
Latest member
Da9l87

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top