fbpx
Search
Close this search box.

Formula Debugging in Excel – Tip [spreadcheats]

Share

Facebook
Twitter
LinkedIn

Can you imagine building a complex worksheet without formulas? I can’t. While no one can dispute the usability of formulas, we all know how painful it is when an excel formula returns a mysterious error and we don’t know what is causing it.

When I learned IF() formula for the first time, I have spent a whole Sunday morning debugging a stupid error in a grade calculation formula.

So as part of our spreadcheats series, we will learn a handy trick you can use to debug formulas and fix the errors quickly.

Assuming we have a moderately lengthy formula like this
=IF(AVERAGE(B2:B6)<=AVERAGE(C2:C6),MAX(B2:B6),MAX(C2:C6))
and we want to know where the error is occurring

  1. Select the cell with formula.
  2. Now click on the formula bar
  3. Just select the parts the formula and press F9 (for eg: the first average() formula)
  4. This will evaluate only the selected part and replaces it with the result. Like this:

  5. Using this technique you can narrow down the errors to particular range or values causing it.
  6. Now that you know where the error is occurring you can wrap that part of formula with an ISERROR() formula to avoid unpleasant surprises.

What is your favorite way of handling errors?

PS: If you have mailed me or commented here and waiting for a response, please give me some more time. I am having trouble getting internet connection in Chennai and visiting browsing center to respond to mails is not a pleasant experience either. I really appreciate your patience. Meanwhile if you know any free wi-fi hot spots in Chennai do let me know through comments. 🙂

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Excel School made me great at work.
5/5

– Brenda

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

letter grades from test scores in Excel

How to convert test scores to letter grades in Excel?

We can use Excel’s LOOKUP function to quickly convert exam or test scores to letter grades like A+ or F. In this article, let me explain the process and necessary formulas. I will also share a technique to calculate letter grades from test scores using percentiles.

35 Responses to “Formula Debugging in Excel – Tip [spreadcheats]”

  1. Peden says:

    Another way to do this would be to invoke the formula helper function. Denoted by the f(x) I believe. This will also evaluate everything, but admittedly pushing the keys is a bit more fancy 🙂

  2. Learn Excel says:

    This is a great Excel tip on debugging. Thanks!

  3. fchaves says:

    Best excel tip ever Chandoo!

  4. Oliver Montero says:

    Excellent. Now debugging a worksheet is much easier.

  5. The.Q says:

    AS we say in Ireland, "that's deadly!" That's a very high compliment, meaning that it's absolutely brilliant. I've been using Excel for ?? years and never knew that existed. Thanks again.

  6. JP says:

    You can also use the formula auditing toolbar, there's a button labelled "Evaluate Formula" which you can use to step through a given formula one calculation step at a time.

  7. Chandoo says:

    @Peden: yeah formula helper toolbar has handy tools for debugging formulas and tracing dependents.
    @Learn Excel: thank you so much...
    @FC: I am so happy you liked it
    @Oliver: learning this trick saved me so much time in both debugging and avoiding future errors. It also helps me to know that right data is coming through lookups and references in the formula.

    @TheQ: That is really a wonderful comment.

  8. Vishal Haria says:

    Cool Trick!
    One needs to press Esc after seeing the result. Else the actual formula gets replaced by the evaluated result.

  9. Chandoo says:

    @JP: yeah formula auditing toolbar is another helpful tool.
    @Vishal : you are right, if you don't press ESC after this, excel replaces the formula with its results.

  10. V.Mohan Kumar says:

    Dear Chando,
    Its really great it saves my time lot. Thanks for the info:)

  11. Sumeet says:

    Hi Chandoo,
    I use PivotTables everday. I want to use division and multiplication in Calculated items in PivotTables. Is it possible? If yes, how to do it.

  12. Ketan says:

    @Sumeet : I suggest to insert the col in your database with required formula and then make pivot table.

    Alternative:
    Check this path : raise pivot table=>click the data field in layout ==>go to option==>select available option from show data as

    @Chandoo : Pls inform how to create the customise equation in above path

  13. Chandoo says:

    @Ketan: thanks for sharing your tips with Sumeet. I use pivot tables very rarely, one reason why we dont have many posts on them here. I will learn them in the next few days and share my thoughts here. 🙂

    @Sumeet: Meanwhile if you come across any other good ways to do this let us all know.

  14. Kate says:

    How did I not know about this?!?!? Wow. What a time saver!

  15. jawad says:

    how to fix one call in formula while other can b change

  16. Glenda says:

    A large multi-page spreadsheet has stopped calculating. The formulas have NOT been changed to their values. This is a year's work. Let's say cells A1 through Z1 on page 2 copy cells A22 through Z22 on the previous page. I enter the + key and targets the corrsponding cell on the previous sheet. Though the formula is there, the result is zero. It's happening out of the blue throughought the workbook. Copying a neighboring cell, copies the formua correctly & targets the correct cells, but the result remains the SAME as in the cell I copied the formula FROM. The workbook is about 70% formulas with the rest being hard data. Evaluate the formula & it tells you to lock the cell to prevent inadvertently changing it. I've tried to do that, but it does not help. I'M GOING CRAZY!

  17. Karthik says:

    Good tip, thanks!

  18. Thanks for your tip - but I was still puzzled when part of my formula was highlighted; I checked the cells it pointed to (as I did before looking for help), but didn't see the problem for a while. Here's what the problem was: I migrated my files from XP, where I saved Works 2002 spreadsheets as Excel. All the formulas were working there. But when I moved them to V7 with Excel instead of Works, one of the rules about formulas was different. Works counted any non-numeric input in a cell used in a formula (example: =c95+q95 where c95 has the string "Hello" in it) as 0 (thus: =c95+q95 yields q95); but Excel counts it as an error. So I suddenly had lots and lots of errors where there was nothing wrong before. The fix was easy: delete or move the bits of text I'd put in. If anyone else happens to be moving spreadsheets from Works to Excel, here's why the formulas suddenly complain "#VALUE"

    I'd also like to ask a question. Is there a way to include BOTH calculated numeric values AND text in the result of a formula? That is, can I say something like =IF(A72<90,A73" Don't worry",A74" Be happy!") I really wish I could mix text and calculated numbers in one of my spread sheets. For now I have 2 different cells; one with the numbers and the adjoining one with the text. It's an extra 31 cells with a formula in each to be maintained from month to month....

  19. [...] we use the F9 key to successively evaluate parts of the function it looks like [...]

  20. Steve says:

    Great tip, thanks! This will save me a lot of time & effort. I have a follow-up question.

    If I am debugging a very long formula, I may want to debug several segments in the formula (say, 10 segments in all). After I select the 1st segment, press F9 & display the value, how do I change back to formula mode WITHOUT EXITING the cell, so that I can select the next segment & examine its value again?

    At the moment, I have to press ESC to get out of the cell, then go back to the cell, select the next segment, press F9 again, etc.

    • The_S.Wan says:

      Was this question answered, by any chance? I'm having the same issue..

      Once I've pressed F9, this:
      =IF(AVERAGE(B2:B6)<=AVERAGE(C2:C6),MAX(B2:B6),MAX(C2:C6))
      changes to this:
      =IF(4.2<=AVERAGE(C2:C6),MAX(B2:B6),MAX(C2:C6))

      @Chandoo: Can we revert back while still within the formula? i.e. without exiting the cell and come back just to start all over with the debugging?

      thanks!

      • Hui... says:

        @The S.Wan
        Once you press F9 and it show 4.2
        simply revert to the previous formula by pressing Ctrl+Z

        As you have found pressing Esc reverts but also takes you out of Edit mode

  21. […] Select the TRANSPOSE(B2:B19) portion and press F9. (related: debugging formulas using F9 key) […]

  22. […] Display portion of the formula (F9):  Lastly, this little trick will make your life easier when you are deciphering someone […]

  23. jitu says:

    how to convert a figure in word with the help of excel formula

    like:- 15 - fifteen
    1000 - one thousand

  24. Gretchen says:

    What about if you're using Mac? What key will I press instead of F9? Thanks!

  25. Anant says:

    Great Help. Got the answer to concatenate and then found a link through this. Thanks a lot!!

  26. Sameer says:

    When I save my excel sheet and again opening it the formulas linking sheets of same file disappear and shows value only.

Leave a Reply