Underline

A

Arun

I would like to apply underlining format to a cell where JUST the words are
underlined (the underlining does not extend accross the entire cell). It
seems that it always just underlined the word when I pressed Ctrl-U, but
lately Excel has been putting the underline accross the whole cell as if I
had added a border.
 
T

Trevor Shuttleworth

Pressing Ctrl-U underlined the whole cell when I tried it. You can select
and underline each word in the cell individually but that would be very
labour intensive if you have a lot of cells.

Regards

Trevor
 
G

Gord Dibben

Arun

Try this macro.

Sub underline()
Dim v As Variant, i As Integer
If ActiveCell.HasFormula = False Then
v = Selection(1, 1).Value
For i = 1 To Len(v)
If Not (Mid(v, i, 1)) = Chr(32) Then
Selection(1, 1).Characters(Start:=i, _
Length:=1).Font.underline = True
End If
Next i
End If
End Sub


Gord Dibben MS Excel MVP
 
D

David McRitchie

Or if you just want to work with a single cell with
a text constant (no formula), you should do your
selection on the address bar not in the cell.

To work within the cell you must first use F2 to get
into edit mode, but you are better off using the
address bar.
 

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

Top