The IfError function is an incredibly useful function in Excel and Google Sheets. The purpose of this function is to return a specific value if the another function returns an error. For example, if you have a function =15/0, that would return an error because you cannot divide by zero.
You can accomplish a lot of the same functionality of the IfError function with regular if functions. However, you can never be sure exactly what type of error a formula will throw. The IfError function captures them all.
For example, I was recently doing an analysis of my blogging performance metrics and was using the vlookup function. In that case, I created a chronological list of the blog names. Then, using vlookup, it would return the number of pageviews for that blog from a separate table I downloaded from Google Analytics. If a blog had 0 pageviews in that time period, there would be an error because vlookup couldn’t find a corresponding value from that table. Since I later summed the row of results, any error threw off all of my results. Therefore, I used IfError to return 0 if there’s an error instead of the “#N/A” that it was returning.
Caution
You shouldn’t use this function everywhere because it can limit your ability to debug certain other issues you might face. For example, before I added it into my functions in the above example, I had to make sure all the blog names were inputted correctly. Therefore, I first ran the function without IfError and double checked every blog title that resulted in an error. There are other ways to do this with less manual review, but I only had 150 blogs to go through and ended up with fewer than 5 misspellings.
Leave a Reply