Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Excel, how would I perform the following using the IF condition?

  • If cell is empty then set the background color to red.
  • If cell has a value then set the background color to green.
share|improve this question
4  
To change the background color of a cell, you would use conditional formatting, rather than trying to use the IF() function in a cell formula. –  w3d Oct 15 '12 at 14:13

1 Answer 1

You could apply a regular red fill, then use conditional formatting to make it green if populated, e.g. in conditional formatting use the

"use a formula to determine which cells to format" option with the formula

=A1<>""

assumes formatting applied to cell A1, change as appropriate. For a range of cells just write the formula for the top left cell, e.g. to format B3:J10 this way select that range and use

=B3<>""

share|improve this answer
1  
Alternately, set both rules in Conditional Formatting. For a rule to apply if empty, use something like =A1="". Another nice thing about Conditional Formatting, is that it can be set for one rule to apply to multiple (and non-adjacent) cells. –  Iszi Oct 15 '12 at 16:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.