Sub topic 10
Finding the failing part with Trace Precedents and Evaluate Formula
This chapter assumes you can enter and edit formulas, use cell references and ranges, and know the difference between numbers and text in cells. You have already met the individual error values. Here you will learn two built-in tools that show which part of a formula or which input cell produced the error.
Why a tool helps
A long formula can return one error even though only one small piece is wrong. Reading the formula by eye is slow. Excel gives you two tools on the Formulas tab, in the Formula Auditing group:
- Trace Precedents draws arrows from the cells a formula reads to the cell that holds the formula.
- Evaluate Formula calculates the formula one step at a time so you can see each intermediate result.
Use Trace Precedents to find which input cell is bad. Use Evaluate Formula to find which part of the formula goes wrong.
Trace Precedents
A precedent is a cell that a formula depends on. To trace them:
- Click the cell that shows the error.
- On the Formulas tab, choose Trace Precedents.
- Look at the blue arrows. Each arrow starts at an input cell and points to your formula cell.
- Click Trace Precedents again to follow the chain one more level back.
- Choose Remove Arrows when you are done.
If an input cell is itself an error, the arrows turn red. Follow the red arrows back until you reach a cell that has an error but no red arrows pointing into it. That cell is the source. Every cell after it only passes the error along.
In this chain, fixing D2 does nothing. The repair belongs in B2.
Evaluate Formula
Suppose a cell contains this formula:
=IFERROR(VLOOKUP(E2,A2:B100,2,FALSE),"Not found")*C2The result is #VALUE!. The lookup is wrapped in IFERROR, so you might suspect C2. Evaluate Formula lets you check.
- Click the cell with the formula.
- Choose Evaluate Formula on the Formulas tab.
- The dialog shows the formula with one part underlined. That part is evaluated next.
- Choose Evaluate to replace the underlined part with its value.
- Repeat until the result appears. The step where
#VALUE!first appears is the failing part. - Choose Step In to look inside a nested function, and Step Out to return.
- Choose Close when finished.
Here the underlined VLOOKUP(...) becomes "Not found". The next step multiplies text by C2, and that is where #VALUE! appears. The lookup found no match, IFERROR replaced the failure with text, and the multiplication then failed. The real problem is that the lookup key is missing, and the IFERROR hid it.
Choosing the right tool
| Situation | Better tool |
|---|---|
| The formula refers to many cells and you do not know which one is bad | Trace Precedents |
| One long formula with nested functions | Evaluate Formula |
| An error appears in a total and you suspect a chain | Trace Precedents, following the red arrows |
| A result looks wrong but shows no error | Evaluate Formula |
Common mistakes
- Tracing only one level. The bad cell is often two or three levels back, so click Trace Precedents repeatedly.
- Forgetting that Evaluate Formula shows values at the moment you open it. If you edit a cell, close the dialog and open it again.
- Looking for arrows from another workbook. A dashed arrow with a small sheet icon means the precedent is on another sheet or in another file. Double-click the arrow to jump to it.
Exercise
Cell D10 shows #DIV/0!. Trace Precedents shows red arrows from D10 to C10, and from C10 to B10. B10 has an error but no red arrows pointing into it. Which cell do you fix first, and why?
Show answer
Fix B10. It has an error but no error cells feeding it, so it is the source. C10 and D10 only pass the error along, and they should recalculate correctly once B10 is fixed.
Exercise
Evaluate Formula on =IF(A2>0,B2/C2,"") steps through to B2/C2 and then shows #DIV/0!. Which tool step tells you the cause, and what is the cause?
Show answer
The step where the underlined part B2/C2 is evaluated shows that C2 is zero or blank, because dividing by it gives #DIV/0!. The fix is to check C2 in the IF condition, for example =IF(C2=0,"",B2/C2).