Solved

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

Posted on 2014-11-24
13
104 Views
Last Modified: 2014-11-24
I would like to change the font color of the first character in a string within a cell.  Can this be done?
0
Comment
Question by:tballin
  • 7
  • 4
  • 2
13 Comments
 
LVL 39

Expert Comment

by:als315
Comment Utility
You should have no problems if you will do it manually. How do you like to accomplish this?
0
 

Author Comment

by:tballin
Comment Utility
I would like to setup a formatting rule - there's just too many cells to do this manually.
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
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?
0
 

Author Comment

by:tballin
Comment Utility
A macro will work.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Sub HighLightCell()

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

End Sub
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Or
Sub HighLightCell()

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

End Sub
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:tballin
Comment Utility
When I run this, the entire cell takes on the new format, not just the first character.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Did you copy it correctly? This is what I see.
?
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Or the following where I did Range("A1").Characters(1, 1).Font.Size = 24.
??
0
 

Author Comment

by:tballin
Comment Utility
I might be copying it wrong... but here's what I'm seeing:

code.JPGsheet.JPG
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Hmmm. It seems that it does that for numbers. Let me see what I can do.
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Sorry but if it's a number (even formatted as text) I don't think it can be done.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now