Thanks Thanks:  0
Likes Likes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Superscript Subscript - part of a cell - using VBA

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there a way to superscript or subscript only part of a cell's text? The forum below provides VBA to superscript an entire cell.

    How about just part of a cell?

    e.g. A1 = m3, I want to superscript the 3.

    http://www.mrexcel.com/board/viewtop...ic=856&forum=2

    [ This Message was edited by: Cosmos75 on 2002-04-19 11:39 ]

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Type in 'M', click on Format- Cells- Font and change to subscript, then type in the 3. You might be able to build yourself a custom toolbar to do this with a single click.

  3. #3
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    A1 = m3

    Yeah, highlight the "3", right click, choose "Format Cells" and then tick the Subscript/Superscript (whatever) box that you want.

  4. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    And this is a complete pain in the @$$. At least Word has shortcut keys for this.

  5. #5
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Austin, Texas USA
    Posts
    11,654
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-19 10:56, Cosmos75 wrote:
    Is there a way to superscript or subscript only part of a cell's text?
    Yes... as long as the "cell's text" isn't the result of a formula.

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    SORRY! I guess I should have been more specific, I meant is there a way to do this from within VBA?

  7. #7
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    cosom

    hi yes you can im sure i have some code SOMEWHERE i have no excel at home, ill try to find it and it will find test and super it.


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  8. #8
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Just recording a macro gives this (minus all the bumf):

    With ActiveCell.Characters(Start:=2, Length:=1).Font
    .Superscript = False
    .Subscript = True
    End With

    Just replace ActiveCell with a Range and select the Start of the letters to be Subscripted and how many you want to be done.

    [ This Message was edited by: Mudface on 2002-04-19 11:19 ]

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mudface,

    What if I don't know where the I want to start the superscript or how many characters there are?

    What about if I am just typying in text, and the use the arrow to go back and select part of the text, and then run a macro to superscript the selected part of the text?

    I hope that wasn't too convoluted....

    Say I type "The volume of the cylinder is 42 m3", the press the arrow key once (to have the cursor before 3, hold down shift, go forwar to select 3. NOW, I want to run a macro or script to superscript the selected part of the text, in this case the 3.

    Can this even be done??

    [ This Message was edited by: Cosmos75 on 2002-04-19 11:24 ]

  10. #10
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    1 You're stuck.
    2 Not sure, I don't think there's a way to pick up that you've actually selected something within a cell (although no doubt I'll be proved wrong . In any case it'd probably be just as quick to change the format via the main menu.

Some videos you may like

User Tag List

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
  •