How to Use the IF-THEN Function in Excel (2024)

What to Know

  • The syntax of IF-THEN is =IF(logic test,value if true,value if false).
  • The "true" value tells the function what to do if the result of the logic test is true.
  • The "false" value tells the function what to do if the result of the logic test is false.

This article explains how to write and use the IF function (also known as IF-THEN) in Excel. Instructions apply to Microsoft 365, Excel 2021, 2019, 2016, 2013, 2010; Excel for Mac, and Excel Online.

How to Write IF-THEN in Excel

The IF functionin Excel is a way to add decision-making to yourspreadsheets. It testsa condition to see if it's true or false and then carries out a specific set of instructions based on the results.

For example, you could set an IF to turn back results 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."

The IF-THEN function's syntax includes the name of the function and the function arguments inside the parenthesis.

This is the proper syntax of the IF-THEN function:

 =IF(logictest,valueiftrue,valueiffalse)

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 sets of instructions with a comma between them.

  • The first item tells the function what to do if the comparison is true.
  • The second item tells the function what to do if the comparison is false.

A Simple IF-THEN Function Example

Before moving on tomore complex calculations, let's look at a straightforward example of an IF-THEN statement.

Our spreadsheet is set up with cell A1 as $100. We can input the following formula into B1 to indicate whether the value is larger than $1000.

 =IF(A1>1000,"PERFECT","TOOSMALL")

This function has the following parts:

  • A1>1000 tells Excel to check whether the value in cell A1 is larger than 1000.
  • "PERFECT" returns the word PERFECT in cell B1 if A1 is larger than 1000.
  • "TOO SMALL" returns the phrase TOO SMALL in cell B1 if A1 is not larger than 1000.

How to Use the IF-THEN Function in Excel (1)

In plain language, this IF function says, "If the value in A1 is greater than 1,000, write PERFECT. Otherwise, write TOO SMALL."

The comparison part of the function can compare only two values. Either of those two values can be:

  • Fixed number
  • A string of characters (text value)
  • Date or time
  • Functions that return any of the values above
  • A 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. You can make the IF function very advanced by embedding additional calculations or functions inside it.

When inputting true or false conditions of an IF-THEN statement in Excel, you need to use quotation marks around any text you want to return, unless you're using TRUE and FALSE, which Excel automatically recognizes. Other values and formulas don't require quotation marks.

Inputting Calculations Into the IF-THEN Function

You can embed different calculations for the IF function to perform, depending on the comparison results. This example uses one calculation for the tax rate, 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.

 =IF(B2>50000,B2*0.15,B2*0.10)

If the value in B2 is greater than 50,000, the IF function will multiply it by 0.15. If it's lower, the function will multiply it by 0.10.

You can also embed calculations into the comparison side of the function. In the above example, you might estimate that taxable income will only be 80% of total income. With this in mind, you can change the above IF function to the following:

 =IF(B2*0.8>50000,B2*0.15,B2*0.10)

This formula first multiplies the input value (in this case, B2) by 0.8, and then it compares that result to 50,000. The rest of the function works the same.

How to Use the IF-THEN Function in Excel (2)

Because Excel treats commas as breaks between parts of a formula, don't use them when entering numbers higher than 999. For example, type 1000, not 1,000.

Nesting Functions Inside of an IF Function

You can also embed (or "nest") a function inside an IF statement in Excel. This action 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 in Excel:

 =IF(AVERAGE(B2:B6)>85,"Excellent!","NeedsWork")

In English: "If the average of the values from B2 to B6 is greater than 85, type Excellent! Otherwise, type 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.

How to Use the IF-THEN Function in Excel (3)

FAQ

  • How do I create multiple IF-THEN statements in Excel?

    Use Nesting in Excel to create multiple IF-THEN statements. Alternatively, use the IFS function.

  • How many IF statements can you nest in Excel?

    You can nest up to 7 IF statements within a single IF-THEN statement.

  • How does conditional formatting work in Excel?

    With conditional formatting in Excel, you can apply more than one rule to the same data to test for different conditions. Excel first determines if the various rules conflict, and, if so, the program determines which conditional formatting rule to apply to the data.

Was this page helpful?

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Tell us why!

How to Use the IF-THEN Function in Excel (2024)

FAQs

How to Use the IF-THEN Function in Excel? ›

The syntax of IF-THEN is =IF(logic test,value if true,value if false). The "true" value tells the function what to do if the result of the logic test is true. The "false" value tells the function what to do if the result of the logic test is false.

How do you use the IF THEN statement in Excel? ›

The syntax of IF-THEN is =IF(logic test,value if true,value if false). The "true" value tells the function what to do if the result of the logic test is true. The "false" value tells the function what to do if the result of the logic test is false.

How do you write an if then formula in Excel with multiple criteria? ›

The Excel IF function with two or more conditions follows a generic formula: =IF(AND(condition1, condition2, ...), value_if_true, value_if_false). What this means is that “If condition 1 is true AND condition 2 is true, return value_if_true; else return value_if_false.”

What is the correct formula for the IF function in Excel? ›

=IF(logical_test, value_if_true, value_if_false)

The function uses the following arguments: Logical_test (required argument) – This is the condition to be tested and evaluated as either TRUE or FALSE. Value_if_true (optional argument) – The value that will be returned if the logical_test evaluates to TRUE.

Can you do multiple if then statements in Excel? ›

While Excel will allow you to nest up to 64 different IF functions, it's not at all advisable to do so. Why? Multiple IF statements require a great deal of thought to build correctly and make sure that their logic can calculate correctly through each condition all the way to the end.

How to write if then statement? ›

Hypotheses followed by a conclusion is called an If-then statement or a conditional statement. This is read - if p then q. A conditional statement is false if hypothesis is true and the conclusion is false. The example above would be false if it said "if you get good grades then you will not get into a good college".

How do you write an ifs then formula in Excel? ›

The function's syntax is =IFS(logical_test1, value1, [logical_test2, value2], …), allowing up to 127 conditions. It is useful for grading systems, categorizing data, and more. Errors occur if no conditions are met or if arguments are incorrect.

How to use if with multiple conditions? ›

To put two conditions in an IF formula in Excel, you can use the AND or OR function along with the IF function. For example, =IF(AND(A1>50, B1>60), “Pass”, “Fail”) will check if the value in cell A1 is greater than 50 and the value in cell B1 is greater than 60.

How to put 3 conditions in if formula in Excel? ›

Using the below-given formulas, you can use the IF function with 3 conditions in Excel:
  1. Method 1: Nested IF Function. =IF(C2<15, “Bad”, IF(C2<20, “o*k”, IF(C2<25, “Good”, “Great”))
  2. Method 2: IF Function with AND Logic. ...
  3. Method 3: IF Function with OR Logic. ...
  4. Excel IFS Function: ...
  5. SWITCH Function:

How to do an if or statement in Excel? ›

How to use the OR function in Excel with the IF function
  1. Enter the IF function. Click on the cell where you want the result to appear. ...
  2. Insert the OR function. Insert the OR function as the first argument of the IF function. ...
  3. Insert true and false values. After adding a closing parenthesis to the OR function, add a comma.
Jun 27, 2024

How do you write an if then SUM formula in Excel? ›

For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John." To sum cells based on multiple criteria, see SUMIFS function.

What is a nested if statement? ›

Nested IF functions, meaning one IF function inside of another, allows you to test multiple criteria and increases the number of possible outcomes. We want to determine a student's grade based on their score. If Bob's score in B2 is greater than or equal to 90, return an A.

How to do conditional formatting in Excel if then? ›

How to use conditional formatting in Excel
  1. Select a range.
  2. In the Home tab of your ribbon, click Conditional Formatting. ...
  3. In the Conditional Formatting panel that appears, click the New Rule icon, which looks like a plus sign ( + ).
  4. Select the rule type (and, if needed, customize the condition).
Aug 29, 2023

What is an example of a nested if statement? ›

A nested if statement is an if-else statement with another if statement as the if body or the else body. Here's an example: if ( num > 0 ) // Outer if if ( num < 10 ) // Inner if System. out.

What is the conditional formula in Excel? ›

Conditional formulas start with the IF function, which is followed by the condition you want to check and the action you want to take. For example, if you wanted to check if a cell contains a number greater than 5, you would use the formula =IF(A1>5, "Yes", "No").

References

Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 5630

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.