How to Use IF and VLOOKUP Nested Function in Excel
To use IF and VLOOKUP nested functions in Excel, follow these steps:
- Open Excel and create a new worksheet or open an existing worksheet.
- Identify the data range for the VLOOKUP function. This should include the data you want to look up and the data you want to return based on the lookup value.
For example, let's say you have the following data range (A1:B5):
A B
1 ID Name
2 1001 John
3 1002 Jane
4 1003 Mike
5 1004 Alice
In this example, you want to search for the ID in column A and return the corresponding Name in column B.
- Decide on the lookup value for the VLOOKUP function. This can be a static value or a cell reference.
For example, let's say you want to look up the ID in cell D1 and display the result in cell E1.
- Now let's create the nested IF and VLOOKUP function in cell E1. The syntax for the nested function is:
=IF(ISNA(VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])), "Value_if_NA", VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]))
- In the example, type the following formula in cell E1:
=IF(ISNA(VLOOKUP(D1, A1:B5, 2, FALSE)), "ID not found", VLOOKUP(D1, A1:B5, 2, FALSE))
This formula checks if the VLOOKUP function returns an error (ID not found) and if so, displays "ID not found." If there's no error, it displays the corresponding name.
- Press Enter to complete the formula.
- Test the formula by entering an ID in cell D1. If the ID exists in the data range, the corresponding name will appear in cell E1. If not, "ID not found" will be displayed.
Using IF and VLOOKUP nested functions in Excel allows you to perform a lookup and handle errors more gracefully, ensuring your worksheet remains clean and professional-looking.
Did you find this useful?