Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. – w3dk Oct 15 '12 at 14:13

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .