Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
James C
 
Posts: n/a
Default 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   Report Post  
Bob Phillips
 
Posts: n/a
Default

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
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
How do I change a macro to use relative cell addresses? Roger D Excel Discussion (Misc queries) 2 July 30th 05 07:35 PM
Cell color based upon cell value My View Excel Discussion (Misc queries) 11 July 6th 05 03:59 AM
Cell text color change Steffen Excel Discussion (Misc queries) 1 February 23rd 05 10:31 PM
Change cell back color on click Dave Peterson Excel Discussion (Misc queries) 0 January 24th 05 10:50 PM
Color change in cell when > 49.99 Slumbering Gorilla Excel Discussion (Misc queries) 1 January 24th 05 08:11 PM


All times are GMT +1. The time now is 06:03 PM.

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"