View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Thulasiram[_2_] Thulasiram[_2_] is offline
external usenet poster
 
Posts: 106
Default Changing Font in a Cell

On Aug 31, 10:06 am, "Robert Sheppard" wrote:
How can I change the font of only a portion of the text within a cell. In my
application I want the first portion of text to be Bold and the second
portion of text to be Italics. This is something you can do within Excel but
I cannot figure out how to do it programatically. I can change the font of
the entire cell but not a portion of it.

Any ideas on how I can accomplish this?


Hi Robert,

Try this and tweak it with the font you want

Sub test()

ActiveCell.FormulaR1C1 = "ABCD EFGH"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=6, Length:=4).Font
.Name = "Bodoni MT Black"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B1").Select

End Sub