Using bold and normal font within one cell

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

In Excel you can manually change some of the formatting
for part of a cell. This allows you for example to only
make selected parts of the contents of the cell bold
rather than everything.

Does anyone know how you can do this with VBA?
 
Here is one I just recorded. Of course it needs a LOT of cleaning up to do
just what you want. But, you get the idea. BTW, you cannot do this with a
formula.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 1/8/2004 by Don Guillett
'

'
Range("E9").Select
ActiveCell.FormulaR1C1 = "Date"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Courier"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=3, Length:=2).Font
.Name = "Courier"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
Range("E5").Select
End Sub
 
Paul

Sub CellFont()
With ActiveCell.Characters(Start:=1, length:=3).Font
.ColorIndex = 3
.Bold = True
.Underline = True
End With
With ActiveCell.Characters(Start:=4, length:=3).Font
.Superscript = True
.ColorIndex = 5
End With
End Sub

Adjust to suit.

Gord Dibben Excel MVP
 
Back
Top