Avatar of tballin
tballin
 asked on

How to format the first character of a string in an Excel 2010 cell

I would like to change the font color of the first character in a string within a cell.  Can this be done?
Microsoft Excel

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
als315

You should have no problems if you will do it manually. How do you like to accomplish this?
tballin

ASKER
I would like to setup a formatting rule - there's just too many cells to do this manually.
als315

You can't do it with formatting rule, because in these rules you can change colors only in whole cell, but you can do it with macro. Is it acceptable?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
tballin

ASKER
A macro will work.
Martin Liss

Sub HighLightCell()

    Range("A1").Characters(1, 1).Font.Color = vbRed

End Sub
Martin Liss

Or
Sub HighLightCell()

    Range("A1").Characters(1, 1).Font.Bold = True 'etc.

End Sub
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
tballin

ASKER
When I run this, the entire cell takes on the new format, not just the first character.
Martin Liss

Did you copy it correctly? This is what I see.
?
Martin Liss

Or the following where I did Range("A1").Characters(1, 1).Font.Size = 24.
??
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
tballin

ASKER
I might be copying it wrong... but here's what I'm seeing:

code.JPGsheet.JPG
Martin Liss

Hmmm. It seems that it does that for numbers. Let me see what I can do.
ASKER CERTIFIED SOLUTION
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Martin Liss

This does it
Sub HighLightCell()

    Range("A2").Value = "'" & Range("A2").Value
    Range("A2").Characters(1, 1).Font.Color = vbRed
    Range("A2").HorizontalAlignment = xlRight
    
End Sub

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.