Format part of cell with underline

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,364
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is it possible to format half of a cell with a different format?

I'm using [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=TEXT(G5,"0.00")&CHAR(10)&TEXT(E5,"0.00") and would like to format the first half with an underline so it looks like a division.

Like this

1267.98
66.21
[/FONT]
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You can do it with hard values, but not with a formula.
 
Upvote 0
How can I do it with the hard values? I'm going to use VBA to convert the formula into .value so I suppose I could also use the VBA to underline the first half of the value?

How can this be done? Not the converting to .value part, I can do that, just the underline half of the cell.
 
Upvote 0
Something like
Code:
   With Range("A4")
      .Characters(1, InStr(1, .Value, Chr(10))).Font.Underline = True
   End With
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
How can I do it with the hard values? I'm going to use VBA to convert the formula into .value so I suppose I could also use the VBA to underline the first half of the value?
Why not abandon the formula approach and let VBA do it all...
Code:
Sub UnderlineFirstValue()
  Dim FrmtE As String, FrmtG As String
  FrmtG = Format(Cells(5, "G").Value, "0.00")
  FrmtE = Format(Cells(5, "E").Value, "0.00")
  With Cells(5, "J")
    .WrapText = True
    .Value = FrmtG & vbLf & FrmtE
    .Characters(1, Len(FrmtG)).Font.Underline = True
  End With
End Sub
 
Upvote 0
Thanks Rick. This is appreciated and a great addition. Out of curiosity, how do you ident your code? I use to use the Smart Indenter but the last time I checked it does not work with the newer version. Maybe it's the 32 bit versus 64 bit, I can't remember.
 
Upvote 0
Out of curiosity, how do you ident your code?
Manually... I have been writing code (in several languages over the years) daily since 1981 (well before code indenters were even thought of), so somewhere many years ago now it became automatic for me to indent my code to make it readable to me.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top