Thread: Underline
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
David McRitchie David McRitchie is offline
external usenet poster
 
Posts: 903
Default Underline

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.
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Gord Dibben" <gorddibbATshawDOTca wrote in message ...
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

On Fri, 11 May 2007 21:13:00 -0700, Arun wrote:

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.