Solved

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

Posted on 2014-11-24
13
107 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
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 39

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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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