Changing font within cell using VBA

S

stainless

I have a VBA macro in Excel 2003 that puts a word within text already
in a cell. I want this word to appear as normal font when the rest of
the text in the cell is in bold.

How can I define the font of a substring of a cell?

Cheers

Mark
 
Z

Zack Barresse

Hi Mark,

Have you tried the macro recorder? This should give you the basis of code
you need. Here is an example of recorded macro code...


ActiveCell.FormulaR1C1 = "Hello world"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial Black"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
With ActiveCell.Characters(Start:=6, Length:=6).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With


You can do some things to individual characters within a cell, but not too
much. Hopefully this will get you started though. Don't forget about the
macro recorder!
 
J

jan

Mark,

You can use the macrorecorder to see what the VBA-code will become if you
change a cell in the way you wish.

Jan
 
D

Don Guillett

and you could refine it to

with ActiveCell 'untested
.font.fontstyle="Bold"
.Characters(Start:=1, Length:=5).Font.FontStyle = "Regular"
end with
 
Top