Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Color a cell
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't format cell color/text color in Office Excel 2003 in fil | Excel Discussion (Misc queries) | |||
Make text color match cell color with macro? | Excel Discussion (Misc queries) | |||
Excel: Syntax to change cell color based on color of another cell | Excel Worksheet Functions | |||
Can't format cell color/text color in Office Excel 2003 in files . | Excel Discussion (Misc queries) | |||
Default Border, Font Color, and Cell Background Color | Excel Discussion (Misc queries) |