How can i do this in a cell formula in excel?
I want something like this in say cell b1:
=if(now()>a1+14,"RED","WHITE")
where "RED" is the command to change the background color to red, and "WHITE" is the command (or no command at all) to leave it blank.
Range("A1").Interior.Color = RGB(255,0,0)
did not work.
=if(now()>a1+14,Range("A1").Interior.Color = RGB(255,0,0),"")
Basically I put a date in cell a1. If it is 14 or more days later, flag b1's cell red.
Re: How can i do this in a cell formula in excel?
You will want to use Conditional Formatting or use VBA code in the Worksheet_SelectionChange event.
Re: How can i do this in a cell formula in excel?
Okay, Conditional Formatting worked in this 2003 version of Excel for this specific task. Thanks.
I don't think I would have done it this way 10 years ago (perhaps Conditional Formatting like this didn't exist as a feature). Do you know a way to do this using an IF formula in a cell?
The reason I ask is that I think it is more flexible using a cell formula. My next need may be to color a row depending upon the value of 2 cells. I was unsuccessful with Conditional Formatting in this case. Also, using a cell formula may handle more general cases.
Re: How can i do this in a cell formula in excel?
Yes, you can also use an If statement in the formula but then your also limited to what you can do.
VB Code:
=IF(logical_test,value_if_true,value_if_false)
Re: How can i do this in a cell formula in excel?
Quote:
=IF(logical_test,value_if_true,value_if_false)
What I need is the value_if_true code.
For instance, the following code does not work
VB Code:
Range("A1").Interior.Color = RGB(255,0,0)
Re: How can i do this in a cell formula in excel?
Quote:
Originally Posted by RobDog888
but then your also limited to what you can do.
:afrog: