Selecting text in cells & half of the Selected Text to be underLine

  • Thread starter Thread starter Manish Singh
  • Start date Start date
M

Manish Singh

Hai,

I am trying to figure this out that it there any code that would be
avaliable that can help to select the text in the defined cell & make
The half of the selected text to be undeline in a selected Cell ?


Bye
Manish Singh
 
Hi,

You need to use ActiveCell's Characters class. following macros will help you.

Sub FirstHalfUnderLineCell()
With ActiveCell
.Characters(Start:=1, Length:=WorksheetFunction.RoundUp(Len(.Value) / 2, _
0)).Font.Underline = xlUnderlineStyleSingle
End With
End Sub
Sub SecondHalfUnderLineCell()
With ActiveCell
.Characters(Start:=WorksheetFunction.RoundUp(Len(.Value) / 2, 0), _
Length:=(Len(.Value) - WorksheetFunction.RoundUp(Len(.Value) / 2, _
0) + 1)).Font.Underline = xlUnderlineStyleSingle
End With
End Sub

Kind Regards

--
Haldun Alay
"Manish Singh" <[email protected]>, haber iletisinde sunlari yazdi:[email protected]...
Hai,

I am trying to figure this out that it there any code that would be
avaliable that can help to select the text in the defined cell & make
The half of the selected text to be undeline in a selected Cell ?


Bye
Manish Singh
 
Hi,

I tried the code u give but it's doen't help at all, is ther any way
as I am using the vb & I have to make the Text in the Cell(1,1) to be
let the text in the cell be is "Ref No: 23456" , where the 2456 is to
be underline while the Ref No remain the same as it is?
 
Hi,
"Ref No: 23456"
Now it is more clear... Use this macro.

Sub UnderLineCell()
Const StartPos = 8 ' Length of "Ref No: "
With ActiveCell
.Characters(Start:=StartPos + 1, _
Length:=(Len( _
.Value) - StartPos)).Font _
.Underline = xlUnderlineStyleSingle
End With
End Sub

Kind regards.

--
Haldun Alay
"Manish Singh" <[email protected]>, haber iletisinde sunlari yazdi:[email protected]...
Hi,

I tried the code u give but it's doen't help at all, is ther any way
as I am using the vb & I have to make the Text in the Cell(1,1) to be
let the text in the cell be is "Ref No: 23456" , where the 2456 is to
be underline while the Ref No remain the same as it is?
 

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