In the latest instalment of his series counting down the "Top 12" of Excel function combinations, Liam Bastick considers IFERROR FORMULATEXT.
Continuing our Top 10 countdown, we are now in the home straight as we arrive at the Top 3. The 3rd of 12 is a very useful combination: IFERROR FORMULATEXT.
Let’s consider them individually to begin.
IFERROR
IFERROR first came into being back in Excel 2007. It was something users had continued to ask Microsoft for. At the time of writing, there are 13 IS functions, ie, functions that give rise to a TRUE or FALSE value depending upon whether a certain condition is met:
- ISBLANK(reference): checks whether the reference is to an empty cell
- ISERR(value): checks whether the value is an error (e.g. #REF!, #DIV/0!, #NULL!). This check specifically excludes #N/A
- ISERROR(value): checks whether the value is an error (e.g. #N/A, #REF!, #DIV/0!, #NULL!). This is probably the most commonly used of these functions in financial modelling
- ISEVEN(number): checks to see if the number is even
- ISFORMULA(reference): checks to see whether the reference is to a cell containing a formula
- ISLOGICAL(value): checks to see whether the value is a logical (TRUE or FALSE) value
- ISNA(value): checks to see whether the value is #N/A. This gives us the rather crude identity ISERR + ISNA = ISERROR
- ISNONTEXT(value): checks whether the value is not text (N.B. blank cells are not text)
- ISNUMBER(value): checks whether the value is a number
- ISODD(number): checks to see if the number is odd. Personally, I find the number 46 very odd, but Excel doesn’t
- ISOMITTED(argument): checks to see whether an argument is missing based upon a LAMBDA function
- ISREF(value): checks whether the value is a reference
- ISTEXT(value): checks whether the value is text.
You get the idea. As mentioned previously, sometimes you need to trap errors that may originate from a formula that is correct most of the time. Where possible, you should be specific with regard to what you are checking, eg
=IF(Denominator=0, error_trap, Numerator/Denominator)
In this example, I am checking to see whether the Denominator is zero. I could use this formula instead:
=IF(ISERROR(Numerator/Denominator), error_trap, Numerator/Denominator)
The difference here is that this will check for anything that may give rise to an error:
Do you see the problem here? I have to put the same formula in twice. If that is a long formula, then the calculation becomes doubly long. This is where IFERROR comes in; it halves the length of the calculation but still achieves the same effect
=IFERROR(calculation, error_trap)
Essentially, this formula is the illegitimate lovechild of IF and ISERROR. It checks to see whether the calculation will give rise to a prima facie error. If it does, it will return error_trap; otherwise, it will perform the said calculation, eg,
You shouldn’t just sprinkle IFERROR throughout your models like your formulae are confetti. Used unwisely, IFERROR can disguise the fact that your formula isn’t working correctly and that modifications to the logic may be required. Try to use it sparingly.
Sometimes you have to use IF and ISERROR in combination anyway:
=IF(ISERROR(calculation), error_trap, different_calculation)
In this example, the formula is checking to see whether a particular calculation gives rise to an error. If it does, the error_trap will be referenced in the usual way, but if not a different_calculation (not the calculation used for the test) will be computed.
These two methodologies should be mastered. You will create more robust and flexible models once your error become a thing of the past. Not just the model – but your own expertise – will become more trusted in your organisation if users never encounter prima facie errors in your model.
FORMULATEXT
New in Excel 2013, this is one of the most used functions in our neck of the woods. It’s a really useful tool for documenting formulae, as FORMULATEXT returns a formula as a text string. People have been writing User-Defined Functions (UDFs) for years to replicate that!
The FORMULATEXT function employs the following syntax to operate:
FORMULATEXT(reference)
The FORMULATEXT function has the following argument:
- reference: this is required and represents a cell or a reference to a range of cells.
The FORMULATEXT function returns what is displayed in the Formula bar if you select the referenced cell, where the reference argument can be to another worksheet or workbook.
FORMULATEXT returns the #N/A error value if:
- the cell used as the reference argument does not contain a formula
- the formula in the cell is longer than 8,192 characters
- the formula cannot be displayed in the worksheet; for example, due to worksheet protection
- an external workbook that contains the formula is not open in Excel.
Interestingly, entering a reference to the cell in which you are entering the function as the argument will not result in a circular reference warning. FORMULATEXT will successfully return the formula as text in the cell. Indeed, this observation gives rise to one of my favourite Excel examples:
IFERROR FORMULATEXT
Word to the Wise
The top 3 continues next month.
Archive and Knowledge Base
This archive of Excel Community content from the ION platform will allow you to read the content of the articles but the functionality on the pages is limited. The ION search box, tags and navigation buttons on the archived pages will not work. Pages will load more slowly than a live website. You may be able to follow links to other articles but if this does not work, please return to the archive search. You can also search our Knowledge Base for access to all articles, new and archived, organised by topic.