+ Reply to Thread
Results 1 to 13 of 13

format text in cell

Hybrid View

  1. #1

    format text in cell

    I am trying to enter distances in Excel cells and want the feet to be
    normal script and the inches be in underlined superscript. Is there a
    VBA code that will automatically convert the last two digits entered
    into the cell? Any help will be appreciated.


  2. #2
    Tom Ogilvy
    Guest

    Re: format text in cell

    Sub AAA()
    With ActiveCell.Characters(Len(ActiveCell.Value) - 1, 2).Font
    .Superscript = True
    .Underline = True
    End With

    End Sub

    possibly. This only works with constant values - not cells containing
    formulas.

    --
    Regards,
    Tom Ogilvy




    <[email protected]> wrote in message
    news:[email protected]...
    > I am trying to enter distances in Excel cells and want the feet to be
    > normal script and the inches be in underlined superscript. Is there a
    > VBA code that will automatically convert the last two digits entered
    > into the cell? Any help will be appreciated.
    >




  3. #3
    L Scholes
    Guest

    Re: format text in cell

    How do I get this only in selected cells? I have two columns (separated
    by several rows) so I have 4 printable sheets. I only want the
    "Measurement" cells to format this way, not the other, "Description,"
    cells.


  4. #4
    Tom Ogilvy
    Guest

    Re: format text in cell

    Sub AAA()
    for each cell in Range("A2:A20,C2:C20,D2:E20")
    With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    .Superscript = True
    .Underline = True
    End With
    Next
    End Sub

    Change the range reference to match the layout of your data.

    --
    Regards,
    Tom Ogilvy



    "L Scholes" <[email protected]> wrote in message
    news:[email protected]...
    > How do I get this only in selected cells? I have two columns (separated
    > by several rows) so I have 4 printable sheets. I only want the
    > "Measurement" cells to format this way, not the other, "Description,"
    > cells.
    >




  5. #5
    L Scholes
    Guest

    Re: format text in cell

    I used this code in both a module and the code for Sheet1 and it
    doesn't seem to have any effect.??? (When I get this sheet working I
    will change the references as appropriate.)

    Sub AAA()
    For Each Cell In Range("C5:C59,D5:D59")
    With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    .Superscript = True
    .Underline = True
    End With
    Next
    End Sub


  6. #6
    Tom Ogilvy
    Guest

    Re: format text in cell

    This is called rich text formatting and can only be done on cells that
    contain TEXT Constants (not numbers, not formulas). If your cells contain
    numbers, then you would modify it to make them text as I have done below


    Sub AAA()
    For Each Cell In Range("C5:C59,D5:D59")
    cell.Value = "'" & cell.Text
    With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    .Superscript = True
    .Underline = True
    End With
    Next
    End Sub


    --
    Regards,
    Tom Ogilvy

    "L Scholes" <[email protected]> wrote in message
    news:[email protected]...
    > I used this code in both a module and the code for Sheet1 and it
    > doesn't seem to have any effect.??? (When I get this sheet working I
    > will change the references as appropriate.)
    >
    > Sub AAA()
    > For Each Cell In Range("C5:C59,D5:D59")
    > With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    > .Superscript = True
    > .Underline = True
    > End With
    > Next
    > End Sub
    >




  7. #7
    L Scholes
    Guest

    Re: format text in cell

    I used this code in both a module and the code for Sheet1 and it
    doesn't seem to have any effect.??? (When I get this sheet working I
    will change the references as appropriate.)

    Sub AAA()
    For Each Cell In Range("C5:C59,D5:D59")
    With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    .Superscript = True
    .Underline = True
    End With
    Next
    End Sub


  8. #8
    Tom Ogilvy
    Guest

    Re: format text in cell

    What do you have stored in the cells?

    --
    Regards,
    Tom Ogilvy

    "L Scholes" <[email protected]> wrote in message
    news:[email protected]...
    > I used this code in both a module and the code for Sheet1 and it
    > doesn't seem to have any effect.??? (When I get this sheet working I
    > will change the references as appropriate.)
    >
    > Sub AAA()
    > For Each Cell In Range("C5:C59,D5:D59")
    > With Cell.Characters(Len(Cell.Value) - 1, 2).Font
    > .Superscript = True
    > .Underline = True
    > End With
    > Next
    > End Sub
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1