Solved

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

Posted on 2014-11-24
13
109 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

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

Expert Comment

by:Martin Liss
ID: 40462412
Sub HighLightCell()

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

End Sub
0
 
LVL 47

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 47

Expert Comment

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

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 47

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 47

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 47

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
usage of ms/excell 3d maps in ms/access 2016 6 41
need copy macro to select range to copy 23 48
Excel shared spreadsheet 12 36
Why Won't My Excel Workbook Refresh The Data 2 40
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

737 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