2 different formats of text in a single cell?

M

mopgcw

Is it possible to have more than one format for a text string in a cell?

For example, I have the formula:

=i_currency&TEXT(+$C$13/landarea,"#,###.##")&"/"&landunit,"")

How can I bold or italicize part of the text string?

thanks
George
 
R

Rick Rothstein

You can't bold or italicize (or do any other font formatting to) part of a
string of text if that text is displayed as the result of a worksheet
formula... only text constants can have parts of its text formatted
differently from the rest.
 
R

Rick Rothstein

Enter the text "Some bold and red words" in A1 and then give this code a
try...

Sub Test()
Dim R As Range
Dim Word As String
Dim Position As Long
Set R = Range("A1")
' Clear any exiting font formatting
R.Characters.Font.Bold = False
R.Characters.Font.ColorIndex = xlAutomatic
' Make a word bold
Word = "Bold"
Position = InStr(1, R.Value, Word, vbTextCompare)
R.Characters(Position, Len(Word)).Font.Bold = True
' Make the color of a word red
Word = "red"
Position = InStr(1, R.Value, Word, vbTextCompare)
R.Characters(Position, Len(Word)).Font.ColorIndex = 3
End Sub
 
M

mopgcw

David & Rick

THANKS, this was VERY helpful.

That's why this is such a great forum.

Take care,
George
 

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