Nesting IF Worksheet Functions

If you have done any programming, you know that you can create conditional statements known as If…Then statements. Basically, these statements give you a way to say “If this is true, then do that.” Excel provides an IF worksheet function to accomplish essentially the same thing in a formula.

You already know how to use the IF function because it was covered in other ExcelTips. What you may not know is that you can nest IF functions. For instance, consider the situation where you want to return a value if two other conditions are true. If cell B5 contains a temperature setting and cell B6 contains a pressure setting, you may want cell B7 to contain the words “TOO HIGH” if B5 is greater than 100 and cell B6 is greater than 50. To do something like this, you could use the following formula:

=IF(B5>100,IF(B6>50,"TOO HIGH",""),"")

Notice that there are two IF functions here. The first one checks to see if the value of B5 is greater than 100. If it is, then the next IF function is invoked. This one checks to see if B6 is greater than 50. If it is, then the words “TOO HIGH” are displayed in the cell. If either of the conditional statements fail, then nothing is displayed in the cell.