Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Make last character in cell superscript

This is a discussion on Make last character in cell superscript within the Excel Questions forums, part of the Question Forums category; This is an example off MS Help. This works if the last character is alpha, but fails if it is ...

  1. #1
    Board Regular
    Join Date
    Aug 2005
    Posts
    2,876

    Default Make last character in cell superscript

    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?

    [size=9]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

  2. #2

    Join Date
    Feb 2003
    Location
    Gurgaon/Thrissur
    Posts
    2,615

    Default

    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

  3. #3
    Board Regular
    Join Date
    Aug 2005
    Posts
    2,876

    Default

    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
    my site: www.ecboardco.com
    was built w/ a tremendous amount of help and guidance from mrexcel and a few dedicated board members: A Huge Thanks!

  4. #4

    Join Date
    Feb 2003
    Location
    Gurgaon/Thrissur
    Posts
    2,615

    Default

    Do you have a sheet named "Sheet1"?

  5. #5
    Board Regular
    Join Date
    Aug 2005
    Posts
    2,876

    Default

    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
    my site: www.ecboardco.com
    was built w/ a tremendous amount of help and guidance from mrexcel and a few dedicated board members: A Huge Thanks!

  6. #6

    Join Date
    Feb 2003
    Location
    Gurgaon/Thrissur
    Posts
    2,615

    Default

    It works fine for me. I don't know what exactly causing the error

  7. #7
    Board Regular
    Join Date
    Aug 2005
    Posts
    2,876

    Default

    what value do you have in A1
    my site: www.ecboardco.com
    was built w/ a tremendous amount of help and guidance from mrexcel and a few dedicated board members: A Huge Thanks!

  8. #8
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,649

    Default

    Doug

    It isn't possible to superscript part of a number.
    If posting code please use code tags.

  9. #9
    Board Regular
    Join Date
    Aug 2005
    Posts
    2,876

    Default

    Hmmmm,
    I wonder what Kris got then?

    Kris? What value do you have in "A1"?

  10. #10
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,649

    Default

    Doug

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

    What are you actually trying to achieve?
    If posting code please use code tags.

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com