How to save watch list in Excel 2010 VBA ?

Posted on 2014-08-13
Last Modified: 2014-08-14

I was hoping there was a way to either save or programmatically add variables to the watch list in Excel VBA ?

I just have a procedure with a fair few variables (like 25) and I don't want to add them everytime I open this file and continue programming and debugging it.

Any help appreciated.

Question by:slobber72
    LVL 23

    Expert Comment

    The object model doesn't have any way (AFAIK) of addressing the Watch window so I think it is impossible to do what you need. Hope I'm wrong!
    LVL 44

    Accepted Solution

    Unfortunately there's no way to do that with VBA while you are debugging Excel. Probably the best that you could do if the variables have global scope (or you change them so that they are global) would be to write a sub that contains a list of Debug.Print statements for each variable you are interested in. At that point you could simulate a "Watch Expression" watch by setting a breakpoint and calling that sub from the Immediate Window.

    If you are interested here's a link to an article I wrote on debugging.

    Author Closing Comment

    Thanks for the feedback. I think I will rethink how I use debug print for this particular instance.


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now