IFERROR function
There is a "special" IF
test designed just to handle errors:
=IFERROR( (D11-C11)/D11, "")
This gives you the calculated value of (D11-C11)/D11 unless the result is an error, in which case it returns a blank.
Explanation
The "if error" value, the last parameter, can be anything; it isn't limited to the empty double-quotes. IFERROR works for any condition that returns an error value (things that start with a #
), like:
#NULL! - reference to an intersection of two ranges that don't intersect
#DIV/0! - attempt to divide by zero
#VALUE! - variable is the wrong type
#REF! - invalid cell reference
#NAME? - formula name, or text within a formula, isn't recognized
#NUM! - invalid number
#N/A - value is not available
This is handy for debugging; the function can be temporarily wrapped around a formula to return some message text when the formula produces an error. It is also a streamlined form of IF test; it doesn't require including an expression to test it, and then including it again to use its result.
Other Spreadsheets
This function is also available to users of other spreadsheet programs. It was added to LibreOffice Calc in version 4.0 (not yet the distributed version in some Linux distros). As @Kroltan points out, though, it is even more streamlined in Google Sheets, where the "if error" value is optional; it defaults to a blank if missing. So in a case like this, where you just want to hide potential error values, Google Sheets can do it with IFERROR(expression)
.