Inputting IF-THEN in Excel
The IF-THEN function in Excel is a powerful way to add decision making to your spreadsheets. It tests a condition to see if it’s true or false and then carries out a specific set of instructions based on the results. For example, by inputting an IF-THEN in Excel, you can test if a specific cell is greater than 900. If it is, you can make the formula return the text “PERFECT.” If it isn’t, you can make the formula return “TOO SMALL.” There are many conditions you can enter into the IF-THEN formula. The IF-THEN function’s syntax includes the name of the function and the function arguments inside of the parenthesis. This is the proper syntax of the IF-THEN function: The IF part of the function is the logic test. This is where you use comparison operators to compare two values. The THEN part of the function comes after the first comma and includes two arguments separated by a comma.
The first argument tells the function what to do if the comparison is true.The second argument tells the function what to do if the comparison is false.
A Simple IF-THEN Function Example
Before moving on to more complex calculations, let’s look at a straightforward example of an IF-THEN statement. Our spreadsheet is set up with cell B2 as $100. We can input the following formula into C2 to indicate whether the value is larger than $1000. This function has the following arguments:
B2>1000 tests whether the value in cell B2 is larger than 1000.“PERFECT” returns the word PERFECT in cell C2 if B2 is larger than 1000.“TOO SMALL” returns the phrase TOO SMALL in cell C2 if B2 is not larger than 1000.
The comparison part of the function can compare only two values. Either of those two values can be:
Fixed numberA string of characters (text value)Date or timeFunctions that return any of the values aboveA reference to any other cell in the spreadsheet containing any of the above values
The TRUE or FALSE part of the function can also return any of the above. This means that you can make the IF-THEN function very advanced by embedding additional calculations or functions inside of it (see below).
Inputting Calculations Into the IF-THEN Function
You can embed different calculations for the IF-THEN function to perform, depending on the comparison results. In this example, one calculation is used to calculate the tax owed, depending on the total income in B2. The logic test compares total income in B2 to see if it’s greater than $50,000.00. In this example, B2 is not larger than 50,000, so the “value_if_false” condition will calculate and return that result. In this case, that’s B2*0.10, which is 4000. The result is placed into cell C2, where the IF-THEN function is inserted, will be 4000. You can also embed calculations into the comparison side of the function. For example, if you want to estimate that taxable income will only be 80% of total income, you could change the above IF-THEN function to the following. This will perform the calculation on B2 before comparing it to 50,000.
Nesting Functions Inside of an IF-THEN Function
You can also embed (or “nest”) a function inside of an IF-THEN function. This lets you perform advanced calculations and then compare the actual results to the expected results. In this example, let’s say you have a spreadsheet with five students’ grades in column B. You could average those grades using the AVERAGE function. Depending on the class average results, you could have cell C2 return either “Excellent!” or “Needs Work.” This is how you would input that IF-THEN function: This function returns the text “Excellent!” in cell C2 if the class average is over 85. Otherwise, it returns “Needs Work.” As you can see, inputting the IF-THEN function in Excel with embedded calculations or functions allows you to create dynamic and highly functional spreadsheets.