Changing Font in a Cell

R

Robert Sheppard

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?
 
T

Thulasiram

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
 

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

Top