# How to Use the IF Function in Excel: Step-by-Step (2023)

The IF function is going to be one of the most useful functions of Excel you’ll ever come across🤩

Once you know how to write the IF function, you’ll use it almost everywhere. With the IF function, Excel tests a given condition.

And returns one value if the condition turns true and another if it turns false. More details about the IF function with many examples of the same await you in the guide below 👇

So jump straight in and take our free sample workbook along with you to practice better.

**Table of Contents**

## How to use the IF function in Excel

The IF function is a logical function of Excel that’ll test a supplied condition. If the condition is true, the IF function would return one value.

And if it is false, it will return another value. And by the way, both these values will be supplied by you. Let’s see this through an example 👩🏫

Here we have a list of some people along with their ages.

Can we use the IF function to see which of these are of the age of 50? For sure. See here:

- Activate a cell.
- Write the IF function as below:

**= IF (B2=50,**

For the first argument of the IF function, write in the condition to be tested 👴

We want to test if the age of each person equals 50. Ages are in column B so we have written the logical condition B2=50.

This tells Excel to test if B2 is equal to 50.

Note that we have used a logical operator (=) to specify the condition. You’d need a logical operator to specify any kind of condition.

- As the next argument, write the value_if_true as below:

**= IF (B2=50, “Equals 50”,**

The value_if_true is the value that Excel would return if the logical condition turned true. It is an optional argument that you can omit ❌

For now, we are setting it to “Equals 50”.

If the value_if_true is omitted, and the logical test turns true, Excel simply returns the Boolean value “TRUE” in its place.

- Next, write in the value_if_false as below:

**= IF (B2=50, “Equals 50”, “Doesn’t equal 50”)**

The value_if_false is the value that Excel would return if the logical condition turned false. It is also an optional argument that you can omit.

We have set it to ‘Doesn’t Equal 50” 🙈

Do not forget to enclose the value_if_true and value_if_false in double quotation marks. Or else would fail to recognize it as a text.

And your IF function would return the #NAME error 🤯

If the value_if_false is omitted, Excel simply returns the Boolean value “FALSE” in its place.

- All good! Hit Enter.

The IF function evaluates if Cell B2 is equal to 50. And as that’s not the case, we get “Doesn’t equal 50” (the value_if_false) 🚩

- Drag and drop the same formula to the whole list.

And there you get the results of the IF function for the entire list🥂

Note how Excel has supplied the value if true (Equals 50) for Cell B3 and B6 where the age is 60. Pretty simple that was!

## IF and logical operators

You can take the IF function game levels ahead by using it together with logical operators.

For example, using the same dataset as above, can we readily see which people are above 50 👀

- Write the IF function as below:

**= IF (B2>50,**

As we want to find the ages that are greater than 50, we are going to define a logical condition using the greater than (>) logical operator.

So we have written the condition as **B2>50** (is B2 greater than 50?).

- Then write the value_if_true and value_if_false as below:

**= IF (B2>50, “Greater than 50”, “Not greater than 50”)**

We want Excel to return the text string “Greater than 50” if the age is more than 50.

And if any age is less than 50, we want Excel to return “Not greater than 50” ✈

- Press Enter.

The IF function evaluates if Cell B2 is greater than 50. And we get the result “Greater than 50” in the very first cell as the age in Cell B2 is 88. (88>50) 👌

- Drag and drop the same formula to the whole list.

Excel evaluates the whole list, and we have our results ready. You can use logical operators like that to test any logical condition.

**Pro Tip!**

You can use a total of 6 logical operators to write any logical test in Excel 6️⃣

- Equal to (=)
- Greater than (>)
- Less than (<)
- Greater than or equal to (>=)
- Less than or equal to (<=)
- Not equal to (<>)

## Other IF formula examples

We’ve yet not had enough of the IF function – and there’s much more to come. Let’s see some more examples of the IF function below 🚴♀️

## IF formula example #1

The above two examples show how you can use the IF function with numbers. But what if you want to use it with text?

You can still do that. Look into the data below.

Some employees worked overtime, whereas others did not. Based on the overtime detail, we need to offer incentives to employees 💰

So can we readily see which employees are getting a bonus this time?

- Write the IF function as below:

**= IF (B2=”Worked Overtime”**

As we want to find which employee did overtime, we defined the logical condition B2=” Worked Overtime”.

This way Excel will see if cell B2 contains the text value “Worked Overtime” or not.

Here’s something for you to take note of. As we have specified text in our logical condition this time, we have enclosed it in double quotation marks.

Excel would fail to test a text logical condition if the text portion is not enclosed in quotation marks 📌

- Then write the value_if_true and value_in_false as below:

**= IF (B2=”Worked Overtime”, “Yes”, “No”)**

For any employee who has worked overtime, Excel will return a “Yes” and vice versa.

- Hit Enter to run the function 🏃♀️

- Drag and drop the same formula to the whole list.

The IF function tests if the cells have the text value “Worked Overtime”. And for all the cells that have this value, the result is a “Yes”. And for the employees who didn’t work overtime, the result is a “No”.

**Pro Tip!**

Did you note that Cell B5 has the status “WORKED OVERTIME” (uppercase characters)?

However, the IF function still finds the logical test to be true, and we have the value “Yes”.

This tells that the IF function is not case-sensitive 🏆

## IF formula example #2

This example is going to be an interesting one. We are going to use the IF function with dates in logical tests.

The image below shows different events scheduled on certain dates 📅

In addition to these events, there is another event planned for 03 March 2023. We will now use the IF function to see if any event clashes with the event on 03 March.

- Write the IF function as below:

**= IF (B2=DATE(2023,03,03)**

We have written the logical test as **B2=DATE(2023,03,03)**

Excel would now test if cell B2 contains the date 03-Mar-2022 or not.

**Pro Tip!**

To write the logical criterion using date, we have used the DATE function that works as follows:

**=DATE(year,mm,dd)**

It is important to know that the logical functions of Excel cannot recognize dates. They instead consider them as text strings 😅

To use dates in the IF function, you must use the DATE function for Excel to convert the date into an understandable format.

Alternatively, you can convert the date into a serial number and then write the IF function like this:

**= IF (B2=44988,**

However, to know the serial number for the targeted date (like 44988 for 03 March 2023), you still need to apply the DATE function separately 🤷♀️

- Then write the value_if_true and value_if_false as below:

**= IF (B2=DATE(2023,03,03), “Yes”, “No”)**

For events that are scheduled on 03 March 2022, Excel will return a “Yes”.

And if that’s not the case, we will get a clean “No” ❌

Interesting, right? Let’s now run the function to see the final results.

- Hit Enter.

- Drag and drop the same formula to the whole list.

Seems like we would have to miss out on Event 3 and Event 5 🙅♂️

## That’s it – Now what?

A long way we’ve come. In the guide above, we have seen how to use the basic IF function, IF function with logical operators, and with single and multiple conditions.

With this, you now know all the ins and outs of the IF function of Excel. I hope you enjoyed reading it as much as I enjoyed writing it ✍

If you found the IF function useful, must know that it only makes one function of the great Excel. This giant spreadsheet software has so much more for you to explore.

To become an Excel maestro, you must have a fine grip on Excel functions. Particularly, the key Excel functions like the VLOOKUP, SUMIF, and IF functions.

Don’t know where to start? Enroll in my 30-minute free email course that will take you through these (and many more) functions of Excel.

## Other resources

Did you know? There is a successor to the IF function that can help you test multiple conditions together (and perform multiple comparisons). The IFS function.

Read our blog on the IFS function and some potential problems with the IFS function here to learn more about it.