automatic font change

  • Thread starter Thread starter L Scholes
  • Start date Start date
L

L Scholes

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.
 
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 lik
the change to be automatic ?

Cari
 
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.
 
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!
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top