Excel If Function
Excel If Function
The result values can display text with an argument such as "OK", calculate a formula such as B12*5,
or display the contents of a cell. Text results must be entered into an IF() function as a character string,
that is, in double quotations. Spaces after the commas in the IF() function are optional.
Examples:
Simple IF() function formulas * Explanation
=IF(B2>100, B2*1.25, B2) If the value in cell B2 is greater than 100, multiply
that value by 1.25, otherwise just display the value in
B2 in the cell where the formula is entered.
=IF(C34>=B34, C34, "Entry not valid") If the value in cell C34 is greater than or equal to the
value in cell B34, display the value in C34, otherwise
display the text "Entry not valid".
=IF(D10<2500, "No", "Yes") If the value in cell D10 is less than 2500, display "No",
otherwise display "Yes".
* As with all other Excel functions, IF() functions can be copied and the logic will copy as well.
© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert
Excel 365, 2021, 2019,& 2016: Data Analysis with the IF Function Page 2
There can be up to 30 expressions as arguments to the AND() function, and all must evaluate true for
the AND() function to evaluate true.
The general structure of OR() function used with IF() function is as follows:
Examples:
Complex IF() function formulas Explanation
=IF(AND(B12>5, B12<20), "Good", If the contents of cell B12 is more than 5 and less
"Invalid") than 20, the text "Good" displays, otherwise the
text "Invalid" appears.
=IF(OR(C5="ABC", C5="DEF", C5="GHI"), If cell C5 contains "ABC", "DEF", or "GHI" (in upper
"Correct entry", "Wrong entry") or lower case), display "Correct entry" in the
formula cell, otherwise display "Wrong entry".
=IF(OR(B36=12, B36=20), "Is a 12 or If B36 contains either 12 or 20, displays the text "Is
20", "Not a 12 or 20") a 12 or 20", otherwise displays "Not a 12 or 20".
=IF(NOT(OR(B36=12, B36=20)), "Not a 12 If B36 contains neither 12 or 20, displays the text
or 20", "Is a 12 or 20") "Not a 12 or 20", otherwise displays "Is a 12 or 20".
© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert
Excel 365, 2021, 2019,& 2016: Data Analysis with the IF Function Page 3
ISERROR(value)
Tests if the value is an error
ISNA(value)
Tests if the value is an error, specifically #N/A
ISBLANK(value)
Tests if the value is blank
ISNONTEXT(value)
Tests if the value is not text
ISNUMBER(value)
Tests if the value is a number
Nested Functions
When a function’s argument is another function, it is called a nested function. With Excel, you can nest
up to 64 levels of functions in a formula! Although many of Excel’s functions can be nested, this is a
common practice with the IF() function. Use of the AND(), OR(), and NOT() functions within the IF()
function are examples of nested functions; additional samples are given below. One of these examples
includes how to handle an IF() function with multiple logical_test and multiple value_if_true
arguments.
Examples:
Nested function formulas Explanation
=IF(ISBLANK(G4),”Data Missing”, If the entry in cell G4 is blank, display "Data Missing".
G4*J4) Otherwise calculate G4*J4.
=IF(D4>DATEVALUE("1/1/22"), "OK", If the date entry in cell D4 is greater than 1/1/22,
"Enter date after 1/1/22") enter OK in cell, otherwise the phrase "Enter date
after 1/1/22" appears.
=IF(AND(ISTEXT(B5), ISBLANK(C5)), This IF() function combines with the Excel functions
"Must enter last name", "") ISTEXT() and ISBLANK(). In this example, if there is
text in cell B5 (such as a first name), and cell C5 is
blank, then the formula cell will display the text
"Must enter last name", otherwise the formula cell
will display nothing.
=IF(AND(A1>=0, B1>=0), A1+B1, This complex IF() function has multiple logical_test
IF(AND(A1<0, B1<0), -A1-B1, "Both arguments and multiple value_if_true arguments. The
Negative and Positive values value_if_false argument is only added at the end of
entered")) the entire expression.
When troubleshooting a nested function or other IF() function that is not working, count the
number of open and close parentheses ( ) to make sure that every function has a matching set
of parentheses. Excel also adds color to each parenthesis to make it easier to match up the sets
of parentheses. Also, count the number of open and close quotations " " to ensure that every
text entry (character string) has a matching set of quotations.
© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert