Computer >> Computer tutorials >  >> Software >> Office

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

If you are looking for the easiest ways to use the IF statement in data validation formula in Excel, then you will find this article useful. Data validation can be useful for making a dropdown list or entering only specified data in a range.
To know more about the usage of the IF statement in data validation formula, let’s start our main article.

Download Workbook

6 Ways to Use IF Statement in Data Validation Formula in Excel

Here, we have some records of some of the products and their corresponding salesperson’s names of a company. By using this dataset, we will try to demonstrate the ways to use the IF statement in the data validation formula in Excel.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

We have used Microsoft Excel 365 version here, you can use any other versions according to your convenience.

Method-1: Using IF Statement to Create a Conditional List with the Help of Data Validation Formula

For creating a conditional list, here we have arranged the full names of the employees under the header First Name and for the first name of the employees, we have used the header Full Name. Using the IF function in the data validation formula we will make the conditional list in the right-side table.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the range E3:E12 and then go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, the Data Validation dialog box will appear.
➤ Select the List option in the Allow box and write the following formula in the Source box and click OK.

=IF($E$3=$B$3,$C$3:$C$12,$B$3:$B$12)

Here, $E$3 is the cell where we want to select the header from the dropdown list, $B$3 is the header name of the first column. When these two values will be equal IF will return the list of the range $C$3:$C$12, otherwise the list will contain the values of the range $B$3:$B$12.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ So, when we click on the drop-down symbol of cell E3, we will get the header First Name and selected it.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Select the first names from the list of the first names of cell E4.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

In this way, we are getting the first names of the salesperson’s names along with the header First Name.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ You can change the header name from First Name to Full Name in cell E3.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Select the full names from the list for the rest of the cells.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Finally, you will get the full names of the employees with the corresponding header.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Read More: How to Make a Data Validation List from Table in Excel (3 Methods)

Method-2: Creating a Dependent Dropdown List by Using IF Statement in Data Validation Formula

In this section, we will create a dependent dropdown list where the Item list will be dependent on the Category list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the cell E5, and then, go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

After that, the Data Validation dialog box will appear.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=$B$3:$C$3

Here, $B$3 is the header Fruits and $C$3 is the header Vegetables.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ After clicking the dropdown symbol of cell E5, you will get the header names on the list, and let’s select Fruits from this list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Now, we will make the items list in cell F5.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=IF($E$5="Fruits",$B$4:$B$12,$C$4:$C$12)

When the value of the cell $E$5 will be equal to “Fruits”, IF will return the range $B$4:$B$12 as a list otherwise the list will contain the range $C$4:$C$12.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Now, for selecting a fruit item like Apple, click on the dropdown list of cell F5 and select this item from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, you will get your desired item Apple for the category Fruits.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ You can select the Category as Vegetables also from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, you will get the list of vegetables in the item list and select the first one (anyone which you prefer) Cabbage from here.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Finally, we are getting the Item Cabbage for the corresponding Category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Read More: Create Data Validation Drop-Down List with Multiple Selection in Excel

Method-3: Using IF Statement and Named Range in Data Validation Formula in Excel

Here, we will use the named ranges along with the IF function in the data validation formula to make a dropdown list.
We have named the range of fruits as Fruits and the range of vegetables as Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the cell E5, and then, go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Afterward, the Data Validation dialog box will appear.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=$B$3:$C$3

Here, $B$3 is the header Fruits and $C$3 is the header Vegetables.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Now, click on the dropdown symbol of cell E5, you will get the header names on the list, and select Fruits from this list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Now, it’s time to make the items list in cell F5.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=IF($E$5="Fruits",Fruits,Vegetables)

When the value of the cell $E$5 will be equal to “Fruits”, IF will return the named range Fruits as a list otherwise the list will contain the named range Vegetables.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Click on the dropdown list of cell F5, and select the item Apple from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, you will get your desired item Apple for the category Fruits.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Select the item Cabbage from the list for the category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Eventually, we are getting the Item Cabbage for the corresponding Category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Read More: How to Use Named Range for Data Validation List with VBA in Excel

Similar Readings:

  • Excel Data Validation Alphanumeric Only (Using Custom Formula)
  • Excel VBA to Create Data Validation List from Array
  • Excel Data Validation Based on Another Cell Value

Method-4: Using the IF and INDIRECT Functions in Data Validation Formula in Excel

Here, we will be using the INDIRECT function along with the IF function to create a data validation formula. And we have the following named ranges Fruits and Vegetables for the fruits range and vegetables range respectively.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the cell F5, and then, go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

After that, the Data Validation dialog box will appear.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=IF($E$5="",Fruits,INDIRECT($E$5))

When the value of the cell $E$5 will be equal to Blank, IF will return the named range Fruits as a list otherwise INDIRECT($E$5) will check the value in the cell $E$5 and then link the value as a reference to the corresponding named range.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Here, we have a blank in cell E5, and for this blank, we are having the list of fruits in the dropdown list of cell F5, and then select the first one Apple from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

For the blank as a Category, we are having the Item as a fruit Apple.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Now, you can write down the Category as Vegetables, and then you will get the list of vegetables in cell F5.|
➤ Select Cabbage from the vegetable list of the Item column.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Eventually, we are getting the Item Cabbage for the corresponding Category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Read More: How to Create Excel Drop Down List for Data Validation (8 Ways)

Method-5: Using Nested IF Functions in Data Validation Formula

Here, we are going to use nested IF functions for multiple conditions in a Data Validation formula to create a dropdown list for the Fruits, Vegetables, and Fruits.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the cell E5, and then, go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, the Data Validation dialog box will appear.
➤ Select the List option in the Allow box, and write the following formula in the Source box

=$B$3:$C$3

Here, $B$3 is the header Fruits and $C$3 is the header Vegetables.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Now, click on the dropdown symbol of cell E5, you will get the header names on the list, and select Fruits from this list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

We will make the items list in cell F5 now.
➤ Select the List option in the Allow box and write the following formula in the Source box

=IF($E$5="Fruits",$B$4:$B$12,IF($E$5="Vegetables",$C$4:$C$12,$D$4:$D$12))

When the value of the cell $E$5 will be equal to “Fruits”, IF will return the range $B$4:$B$12 as a list, otherwise it will go to the next IF function which will check for the value “Vegetables”.
If the condition of this function is fulfilled, then it will return the range $C$4:$C$12 as a list otherwise $D$4:$D$12 will be used in the list.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Click on the dropdown list of cell F5, and select the item Apple from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, you will get your desired item Apple for the category Fruits.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

➤ Select the item Cabbage from the list for the category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, you will have the Item Cabbage for the Category Vegetables.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

For selecting the Category as Fish you will have the list of the fishes in cell F5 of the Item column.
➤ Select the first Item Salmon from the list or any other item.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Eventually, we are getting the Item Salmon for the Category Fish after selecting from the list.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Related Content: Apply Custom Data Validation for Multiple Criteria in Excel (4 Examples)

Method-6: Using IF Statement in Data Validation Formula for Dates

Here, we will try to restrict the entries for the dates of the Delivery Date column in a way that the cells of this column will only accept the dates previous to today’s date (3/21/2022 as m/dd/yyyy format), and for entering dates greater than today’s date we will get an error message. For this purpose, we will be using the TODAY function along with the IF function.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Steps:
➤ Select the range E4:E12, and then, go to the Data Tab >> Data Tools Group >> Data Validation Dropdown >> Data Validation Option.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Then, the Data Validation dialog box will appear.
➤ Select the Custom option in the Allow box, and write the following formula in the Source box

=IF($D$4:$D$12="*",$E$4:$E$12<=TODAY(),$E$4:$E$12="")

If the cells of the range $D$4:$D$12 contains any text string then the cells of the range $E$4:$E$12 will only allow the dates smaller than today’s date or 3/21/2022.

➤ Press OK.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

We can enter any dates without any problem except for the dates greater than today’s date as we can see from the following figure.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

But when we try to enter a date 3/28/2022 which is not either less than or equal to today’s date,

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

we are having the following error message due to the data validation formula we had set previously.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

So, we have filled the cells of the Delivery Date column with dates less than today’s date.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Related Content: How to Use Data Validation in Excel with Color (4 Ways)

Practice Section

For doing practice by yourself we have provided a Practice section like below in a sheet named Practice. Please do it by yourself.

How to Use IF Statement in Data Validation Formula in Excel (6 Ways)

Conclusion

In this article, we tried to cover the ways to use the IF statement in a Data Validation formula in Excel easily. Hope you will find it useful. If you have any suggestions or questions, feel free to share them in the comment section.

Related Articles

  • Excel Data Validation Drop Down List with Filter (2 Methods)
  • How to Apply Multiple Data Validation in One Cell in Excel (3 Examples)
  • Default Value in Data Validation List with Excel VBA (Macro and UserForm)
  • [Fixed] Data Validation Not Working for Copy Paste in Excel (with Solution)
  • How to Use Custom VLOOKUP Formula in Excel Data Validation