Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Macro to change cell text color
OBJECTIVE: I select a range of cells. I want a macro I can run that changes the color of the text based on 3 criteria: (1) if a numeric value w/o an = sign or any mathematical operators, then RED (2) if a forumla w/ an = sign, but no other operators, then GREEN (3) if a formula w/ an = sign and operators, then BLUE Can anyone post this? Thanks. - Jim -- James C ------------------------------------------------------------------------ James C's Profile: http://www.excelforum.com/member.php...o&userid=12114 View this thread: http://www.excelforum.com/showthread...hreadid=395347 |
#2
|
|||
|
|||
Jim,
Here's a shot Dim cell As Range Dim sFormula As String For Each cell In Selection If cell.HasFormula Then sFormula = "SUMPRODUCT(--(ISNUMBER(SEARCH({""+"",""-"",""~*"",""/"",""^""},""" & cell.Formula & """))))" If Evaluate(sFormula) 0 Then cell.Interior.ColorIndex = 5 Else cell.Interior.ColorIndex = 10 End If Else If IsNumeric(cell.Value) Then cell.Interior.ColorIndex = 3 End If End If Next cell -- HTH RP (remove nothere from the email address if mailing direct) "James C" wrote in message ... OBJECTIVE: I select a range of cells. I want a macro I can run that changes the color of the text based on 3 criteria: (1) if a numeric value w/o an = sign or any mathematical operators, then RED (2) if a forumla w/ an = sign, but no other operators, then GREEN (3) if a formula w/ an = sign and operators, then BLUE Can anyone post this? Thanks. - Jim -- James C ------------------------------------------------------------------------ James C's Profile: http://www.excelforum.com/member.php...o&userid=12114 View this thread: http://www.excelforum.com/showthread...hreadid=395347 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I change a macro to use relative cell addresses? | Excel Discussion (Misc queries) | |||
Cell color based upon cell value | Excel Discussion (Misc queries) | |||
Cell text color change | Excel Discussion (Misc queries) | |||
Change cell back color on click | Excel Discussion (Misc queries) | |||
Color change in cell when > 49.99 | Excel Discussion (Misc queries) |