PC Review


Reply
Thread Tools Rate Thread

Conditional format words vs. numbers

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      30th May 2007
HI.

I need to know how to set a conditional format that would font all
numbers black but any letters gray within a cell.

Thanx.

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      30th May 2007
Conditional formatting won't do this kind of character by character formatting.
(You did mean that there was a combination of numbers and letters in the same
cell, right?)



"J.W. Aldridge" wrote:
>
> HI.
>
> I need to know how to set a conditional format that would font all
> numbers black but any letters gray within a cell.
>
> Thanx.


--

Dave Peterson
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      30th May 2007
Not with CF, but VBA will do it

Public Sub FormatCellLetters()
Dim sChar As String
Dim i As Long
With ActiveCell
For i = 1 To Len(.Value)
If Not IsNumeric(Mid$(.Value, i, 1)) Then
.Characters(i, 1).Font.ColorIndex = 15
End If
Next i
End With
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI.
>
> I need to know how to set a conditional format that would font all
> numbers black but any letters gray within a cell.
>
> Thanx.
>



 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      30th May 2007
Conditional formatting affects the entire cell, not individual
characters.

You could use an event macro. For instance, put this in your worksheet
code module (right-click the worksheet tab and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rTargets As Range
Dim rArea As Range
Dim rCell As Range
Dim i As Long

Set rTargets = Intersect(Target, Range("A1,C1"))
If Not rTargets Is Nothing Then
For Each rArea In rTargets.Areas
For Each rCell In rArea
With rCell
.Font.ColorIndex = 16 'all grey
If .Text Like "*#*" Then
For i = 1 To Len(.Text)
Select Case Mid(.Text, i, 1)
Case "0" To "9"
.Characters(i).Font.ColorIndex = 1 'black
Case ".", ","
If i > 1 And i < Len(.Text) Then
If Mid(.Text, i - 1, 3) Like "#?#" Then _
.Characters(i, 1).Font.ColorIndex = 1
End If
Case Else
'do nothing
End Select
Next i
End If
End With
Next rCell
Next rArea
End If
End Sub



In article <(E-Mail Removed)>,
"J.W. Aldridge" <(E-Mail Removed)> wrote:

> HI.
>
> I need to know how to set a conditional format that would font all
> numbers black but any letters gray within a cell.
>
> Thanx.

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      30th May 2007
Correction:

Change

Case "0" To "9"
.Characters(i).Font.ColorIndex = 1 'black

to

Case "0" To "9"
.Characters(i, 1).Font.ColorIndex = 1 'black


In article <jemcgimpsey-(E-Mail Removed)>,
JE McGimpsey <(E-Mail Removed)> wrote:

> Conditional formatting affects the entire cell, not individual
> characters.
>
> You could use an event macro. For instance, put this in your worksheet
> code module (right-click the worksheet tab and choose View Code):
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> Dim rTargets As Range
> Dim rArea As Range
> Dim rCell As Range
> Dim i As Long
>
> Set rTargets = Intersect(Target, Range("A1,C1"))
> If Not rTargets Is Nothing Then
> For Each rArea In rTargets.Areas
> For Each rCell In rArea
> With rCell
> .Font.ColorIndex = 16 'all grey
> If .Text Like "*#*" Then
> For i = 1 To Len(.Text)
> Select Case Mid(.Text, i, 1)
> Case "0" To "9"
> .Characters(i).Font.ColorIndex = 1 'black
> Case ".", ","
> If i > 1 And i < Len(.Text) Then
> If Mid(.Text, i - 1, 3) Like "#?#" Then _
> .Characters(i, 1).Font.ColorIndex = 1
> End If
> Case Else
> 'do nothing
> End Select
> Next i
> End If
> End With
> Next rCell
> Next rArea
> End If
> End Sub
>
>
>
> In article <(E-Mail Removed)>,
> "J.W. Aldridge" <(E-Mail Removed)> wrote:
>
> > HI.
> >
> > I need to know how to set a conditional format that would font all
> > numbers black but any letters gray within a cell.
> >
> > Thanx.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Numbers to Words for UK format tinashe Microsoft Excel Worksheet Functions 0 14th Jun 2011 12:29 PM
Conditional formatting - Numbers and words Mark Andrews Microsoft Excel Misc 1 18th Jun 2009 06:14 AM
format numbers as words - one two three instead of 1 2 3 =?Utf-8?B?YmV0aG1hcnNoYnVybg==?= Microsoft Word Document Management 1 10th Oct 2006 11:11 PM
format numbers as words =?Utf-8?B?MDA3ZGpy?= Microsoft Word Document Management 3 23rd Feb 2006 09:40 AM
Format Numbers into words IntraRELY Microsoft VB .NET 7 5th Dec 2003 08:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:30 AM.