top of page

You are learning Error Handling in MS Excel

How to trap errors in VLOOKUP and other lookup functions?

There are two main ways to trap errors in VLOOKUP and other lookup functions in Excel:

1. IFERROR Function:

- This function allows you to define what you want Excel to display if an error occurs in the lookup function.

Example with VLOOKUP:

```excel
=IFERROR(VLOOKUP(lookup_value, table_array, col_index_num, is_sorted), "Error: Value Not Found")
```

- In this example, if the VLOOKUP function doesn't find a match, "Error: Value Not Found" will be displayed instead of the #N/A error. You can customize the message to anything you like.

2. ISNA Function (or other error checking functions):

- You can combine the lookup function with the ISNA function (checks for #N/A error) or other error checking functions (e.g., ISERR for any error) to perform a specific action based on the error type.

Example with VLOOKUP and ISNA:

```excel
=IF(ISNA(VLOOKUP(lookup_value, table_array, col_index_num, is_sorted)), "", VLOOKUP(lookup_value, table_array, col_index_num, is_sorted))
```

- Here, if VLOOKUP encounters an error, an empty string ("") is displayed. You can choose a different output based on your needs.

Additional Tips:

* You can nest these functions for more complex error handling scenarios.
* Consider using INDEX/MATCH instead of VLOOKUP if you need more flexibility in your lookups, especially when the lookup value isn't in the first column of the table.
* Remember to adjust the lookup_value, table_array, col_index_num, and is_sorted arguments according to your specific VLOOKUP formula.

By implementing these techniques, you can make your spreadsheets more user-friendly and avoid misleading #N/A errors.

bottom of page