Thread: Color a cell
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Color a cell

Does this cover all the bases?
try this
Sub colorpercent()
For Each c In ActiveSheet.UsedRange
If Right(c.NumberFormat, 1) = _
"%" Then c.Interior.ColorIndex = 4
Next
End Sub


--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
a cell can be formatted to display a percent and not have the Percent

style.
You get the percent style if you specifically format it with that style or
you use the % button in the formatting toolbar.

Based on the subsequent post, it sounds like the OP has just a % symbol in
his cells.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
Did you select the cells? It was meant for an example and DOES work. You

can
change to a range

for each c in range("a1:a1000")
or
for each c in range("a1:a"&cells(rows.count,"a").end(xlup).row)
--
Don Guillett
SalesAid Software

"Duncan_J" wrote in message
...
Sorry, but that didn't work, Even created a blank sheet and put

"percent"
in
a few cells and nothing..
I'm I doing somthing wrong?
DJ

"Don Guillett" wrote:

try this. chg from red (3) to whatever color desired.
Sub Macro2()
For Each c In Selection
If c.Style = "Percent" Then
c.Interior.ColorIndex = 3
End If
Next
End Sub

--
Don Guillett
SalesAid Software

"Duncan_J" wrote in message
...
I'm trying to get a formula in my macro to color every cell with a

%
green.
Any help,
Thanks,
DJ