Solved

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

Posted on 2014-11-24
13
108 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 40

Expert Comment

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

Author Comment

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

Expert Comment

by:als315
ID: 40462311
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:tballin
ID: 40462350
A macro will work.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40462412
Sub HighLightCell()

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

End Sub
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40462414
Or
Sub HighLightCell()

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

End Sub
0
 

Author Comment

by:tballin
ID: 40462468
When I run this, the entire cell takes on the new format, not just the first character.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40462479
Did you copy it correctly? This is what I see.
?
0
 
LVL 46

Expert Comment

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

Author Comment

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

code.JPGsheet.JPG
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40462640
Hmmm. It seems that it does that for numbers. Let me see what I can do.
0
 
LVL 46

Accepted Solution

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

Expert Comment

by:Martin Liss
ID: 40462838
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

828 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