Excel IF statement

ok ive found a different way to fix my issue but im keen to know why this one wont work, any excel whizz`s here? or anyone know the best site for me to go to. to ask, cheers
=IF($C$2>=$D$4,"Range(-
$C$2).Font.ColorIndex = 3","Range($C$2).Font-
.ColorIndex = 0")

geek_motorbo, Feb 5, 10:21 pm

Define 'won't work'.

What are you expecting it to do?

geek_vtecintegra, Feb 5, 10:33 pm

Range($C$2) doesn't look right

range isn't a function that I know of
if its a tab name it should have a ! after it

Are you mixing some VBA in with it. Haven't done much with VBA in excel but I didn't think it could be used in a formula

geek_king1, Feb 5, 10:39 pm

I ended up using s simple formula I will hide then applied conditional formatting, yes king it was vba that I was trying to put into an if statement to say if this this cell is greater than or equal to to have it change text colour. which I know you can do in conditional formatting but I also wanted the if statement to contain a simple equation, so it would read if cell is greater than or equal to cell minus 50 then turn the font red, if not then keep it black. so whilst I found a solution It was still bugging me that I couldn't do it with an if statement even without the minus

geek_motorbo, Feb 6, 5:40 am

I don't think that's going to work. You use the If construct to change the value of the cell the formula is linked to. So your formula would happily set the cell contents to "Range($c$2).Font.ColorIn-
dex=3" - unless you can then get Excel to 'run' the cell contents as a macro or program, it wont change any cell properties.

I have always used the conditional formatting - it is pretty powerful once you understand it.

If you are into vba, you can set up you own routines, the following link seems useful if you want to go this route.
http://stackoverflow.com/questions/409434/automatically-execute-an-excel-macro-on-a-cell-change

geek_emmerson1, Feb 8, 11:01 am

I think you have to use conditional formatting to change color, there's some restriction which means you can't do it in a statement.

geek_gyrogearloose, Sep 2, 11:17 pm