Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Color a cell

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Color a cell

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







  #5   Report Post  
Posted to microsoft.public.excel.programming
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











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Color a cell

A modification of the HELP example for FIND

Sub findandcolorpercentgreen()
With ActiveSheet.UsedRange
Set c = .Find("%", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'MsgBox c.Address
c.Interior.ColorIndex = 4
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

--
Don Guillett
SalesAid Software

"Duncan_J" wrote in message
...
Sorry mine doesn't work... I tried yours and it turns the whole 200

columns
green cause they are formated as percentage.. I'll I need is a find "*%"

and
when found makes the cell green...
Cells.Find(What:="*%", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=

_
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate
ActiveCell.Interior.ColorIndex = 4
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Interior.ColorIndex = 4
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Interior.ColorIndex = 4
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Interior.ColorIndex = 4
This works if I can figure out how to loop it...
Thanks guys,
DJ

"Don Guillett" wrote:

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

"Duncan_J" wrote in message
...
I found some code and fiddled with it this works,


Sub ColorCells()
On Error Resume Next
For Each cell In ActiveSheet.Cells.SpecialCells(xlFormulas)
If cell < "%" Then
cell.Interior.ColorIndex = 4
End If
Next
For Each cell In ActiveSheet.Cells.SpecialCells(xlConstants)
If cell < "" Then
cell.Interior.ColorIndex = 4
End If
Next
On Error GoTo 0
End Sub

"Duncan_J" wrote:

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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't format cell color/text color in Office Excel 2003 in fil Tony S Excel Discussion (Misc queries) 1 December 21st 07 01:41 PM
Make text color match cell color with macro? JoeSpareBedroom Excel Discussion (Misc queries) 1 June 26th 07 07:09 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"