+ Reply to Thread
Results 1 to 6 of 6

automatic font change

  1. #1
    L Scholes
    Guest

    automatic font change

    How can I make the last two digits in a cell automatically change to
    superscript and underline? I want to be able to enter 4 or 5 numbers
    and have the last two change automatically in certain cells only.


  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    I have a question for you ...
    What is it for you that triggers the automatic change ?
    or What is the unique identifier of these cells where you would like the change to be automatic ?

    Carim

  3. #3
    Dave Peterson
    Guest

    Re: automatic font change

    First, this kind of formatting doesn't work with formulas or numbers--but it
    will work if you treat your numbers as text (prefix the entry with an apostrophe
    (') or preformat the cell as text.

    So if you want to use this cell in further calculations, I wouldn't do this.
    (It looks kind of like you're writing a check???)

    And the underscore doesn't move directly under the superscripted
    characters--it's still at the bottom of the cell.

    But if you still want...

    rightclick on the worksheet tab that should have this behavior. Select view
    code. Paste this into the code window that just opened up.

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    With Target

    If .Cells.Count > 1 Then Exit Sub
    If Intersect(.Cells, Me.Range("c:c")) Is Nothing Then Exit Sub
    If Application.IsNumber(.Value) Then Exit Sub

    If IsNumeric(.Value) Then
    With .Characters(Start:=Len(.Value) - 1, Length:=2).Font
    .Superscript = True
    .Underline = xlUnderlineStyleSingle
    End With
    End If
    End With

    End Sub

    This code looks for changes in column C (modify to what you want). And delete
    that ".underline = ..." line?????

    You could even enter the values as numbers and have the code convert it to text.

    L Scholes wrote:
    >
    > How can I make the last two digits in a cell automatically change to
    > superscript and underline? I want to be able to enter 4 or 5 numbers
    > and have the last two change automatically in certain cells only.


    --

    Dave Peterson

  4. #4
    L Scholes
    Guest

    Re: automatic font change

    I am a traffic accident investigator and I am using excel to transcribe
    handwritten measurements for legible printing. The format used is to
    write the feet in normal script and the inches in underlined
    superscript. Nothing happens with these numbers except for printing.
    (Sometimes I have thousands of measurements to transcribe, so a macro
    will make entering them much easier.) I have tried your code, but it
    doesn't seem to work. The cells, "C5:D60" are merged (i.e., C5,C6 is
    one, D5,D6 is another, etc.) in both columns. Should I unmerge the
    cells, or is there a way to make this work? Thanks for all the help.
    BTW, it doesn't matter how the cell is formated, text or numbers, it's
    the appearance that matters. Thanks for all of your help!


  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    YES ... forget about merged cells they are a real nuisance when it comes to programming ...
    Then have a go with Dave's recommendation ... Given his level of expertise, I would be surprised if you had any problems with his code.

    Cheers
    Carim

  6. #6
    L Scholes
    Guest

    Re: automatic font change

    His works perfectly without merged cells! Thanks for your help!


+ 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