EXCEL How to use Debug mode.

Anonymous
2022-05-30T13:38:43+00:00

I have a very old spreadsheet that I created probably 10 years ago, that has a bug that I suspect is within the VBA code. It's been years since I've worked with VBA. I need help with the fundamental details of using the Debug feature. For starter, I want to pause the execution at very start of the Open routine. Do I just need to set a breakpoint at the beginning of the Open? Beyond that I need to know how step through execution one command at a time.

My target is to understand how a switch is getting set, that is supposed to be set by the user in the MAIN routine.

I'm open to consulting some resource available, such as a knowledge base article. I'm not keen on just diving in and hacking away at the code.

TIA for your help.SweetTasha

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

9 answers

Sort by: Most helpful
  1. Anonymous
    2022-05-30T22:18:09+00:00

    EliseM thanks for your reply.

    I went to the website you recommend. It starts right off with

    Keys to Step through Code

    As mentioned, you can use the F8 key to step through code, but what happens when you reach a call to another routine?

    It doesn't tell how get to the code that I want to look at.

    SweetTasha.

    0 comments No comments
  2. Anonymous
    2022-05-30T22:31:11+00:00

    If the next step jumps to another routine, then it will simply follow this and go there next.

    Kind Regards,

    Elise

    0 comments No comments
  3. Anonymous
    2022-05-30T22:58:01+00:00

    ronski2 Thanks for your reply.

    you say

    Go into the macro editor

    Put the cursor at the start of the macro

    Somewhere is says Alt+F11 opens the vba editor. I did that. Now how do I know what macro I want to look at.

    Thanks. SweetTasha.

    I thought you already knew ...

    .

    I guess we have to take a step farther back. Are you asking about debugging a formula in a cell, not a macro?

    .

    Debugging formulas in a spreadsheet is another kettle of fish. Is this more of what you are looking for?

    .

    How to edit, evaluate and debug formulas in Excel

    https://www.ablebits.com/office-addins-blog/2016/01/28/evaluate-debug-formulas-excel/

    by Svetlana Cheusheva | updated on March 4, 2021

    In this tutorial, you will learn a few quick and efficient ways to check and debug formulas in Excel. See how to use the F9 key to evaluate formula parts, how to highlight cells that reference or are referenced by a given formula, how to determine mismatched or misplaced parentheses, and more.

    In the last few tutorials, we have been investigating different aspects of Excel formulas. If you've had a chance to read them, you already know how to write formulas in Excel, how to show formulas in cells, how to hide and lock formulas, and more.

    Today, I'd like to share a few tips and techniques to check, evaluate and debug Excel formulas that will hopefully help you work even more efficiently with Excel.

    Another way to debug formulas is to use the Precedents and and Dependants feature to find the cells that contribute to a formula or the cells that are dependent on the results of this cell.

    . Trace Precedents https://corporatefinanceinstitute.com/resources/excel/study/trace-precedents/

    Cells or group of cells that affect the value of the active cell

    HomeResourcesExcel ResourcesStudy › Trace Precedents

    What are Trace Precedents?

    Trace precedents are cells or groups of cells that affect the value of the active cell. Microsoft Excel provides users with the flexibility of doing complex calculations using formulas such as average, sum, count, etc.

    However, the formulas may sometimes return wrong values or even give an error message that you must resolve in order to get the correct values. Excel makes it easier to resolve calculation errors by providing easy-to-use tools such as Trace Precedents that one can use to audit the calculations.

    Summary
    • Trace Precedents tool helps audit a formula in order to understand the relationship between the active cell and other cells.
    • To access trace precedents, go to Formulas Tab > Formulas Auditing > Trace Precedents.

    . Trace Dependents https://corporatefinanceinstitute.com/resources/excel/study/trace-dependents/

    Cells or group of cells that are affected by the selected cell

    HomeResourcesExcel ResourcesStudy › Trace Dependents

    What are Trace Dependents?

    Trace Dependents are defined as the cells or group of cells that are affected by the selected cell. When using the formula auditing tool, Excel displays blue arrows that link the cells that are related to the active cell.

    An Excel spreadsheet sometimes contain multiple formulas, and understanding the relationship between the cells would be a difficult task in the absence of the Trace Precedents and Trace Dependents features in Excel.

    Summary
    • Trace Dependents helps users to analyze the relationship between the cells in a worksheet.
    • Trace dependents are used to show the cells that are affected by the active cell.
    0 comments No comments
  4. Anonymous
    2022-06-01T13:47:35+00:00

    steps(3)

    The comments and technical articles presented by all of you who participated are quite comprehensive. By contrast, my objective is very specific. As I mentioned it was simply to be able to debug code related tswitch/variable that is set in the spreadsheet. My recollection from years ago when I created the spreadsheet was that the workbook Open routine was the "hook" that enabled me to debug the code. And that turns out to be accurate.

    Referring to some of the detail in your comments and technical articles, and a fair amount of trial and error, here's what I came up with.

    *1 Open the spreadsheet file

    *2 Navigate to the MAIN sheet

    *3a Press Alt+ F11

                  **-OR- \*3b Click Developer** 
    

    choose Visual Basic

    Press ENTER

    Image

    * Click View

    Image

    * Click Code

    Image

    * Click Project Explorer button

    Image

    * Click VIEW

    Image

    * Click ThisWorkbook

    * Right-click ThisWorkbook, then click View Code.

    ![Image](https://learn-attachment.microsoft.com/api/attachments/c892d146-afd9-4f2a-9324-5a1de7f28ff7?platform=QnA"https://learn-attachment.microsoft.com/api/attachments/dfcb891f-b642-4f90-a1f6-e5ede0e5eb15?platform=QnA" rel="ugc nofollow">Image

    * Click Edit_Find_ Open

    Image

    ![Image](https://learn-attachment.microsoft.com/api/attachments/d1c15312-e9d6-4cb1-90a2-7c63ad4bcd82?platform=QnA"https://learn-attachment.microsoft.com/api/attachments/4bfca161-d904-4daa-8bd0-51d241c68fc9?platform=QnA" rel="ugc nofollow">Image

    I emphasize that the above isn't a general solution to how to use debug in EXCEL, but a solution applicable only to my specific spreadsheet.

    SweetTasha.

    0 comments No comments