How To Debug An Excel Macro

Excel macros

In the past few weeks, we have taken a deeper look into why and how you can build excel macros, either through recording or through writing/modifying excel VBA code. In a perfect world, the conception of the macro would be the one time that you would even think about it, let alone modify the macro. However, things change and for a variety of reasons, the macro that you build might have some problems such as:

-Being unable to finish its code, getting you this nice window:

-Not giving you the anticipated or desired result
-There might also be some improvements or changes that you’d like to make

The reality is that it’s very unlikely that you will be able to never work on the macro again. When you do, there are a few things that you can do in order to work on the macro and fix any bugs. First off, you can click ALT+F11 buttons to open the “VBA code”. Then, click twice on the module where your code can be found:

After that, you can simply click anywhere in the macro and press F8. Ideally you can see both the code screen and the excel screen so that you can see the macro in action as you move through it. Each time that you click F8, the macro will move to the next line and you will see the yellow marker move with it as well.

If you would like to move to a specific part of the macro

1-simply click in the left margin to the area that you would like, that will create a red marker

Then, you can click anywhere in order and press the “play” button, it will process the macro up to that point, at which time you can press F8 one step at a time.

During the time that you have the redmarker, the macro will automatically pause when it reaches that point. To remove it, simply click on the red marker again.

If at any point you would like to stop and start again, simply click on the top stop button and then you can start over by using the same steps.

Variables

A last point, if you use variables in your macro and would like to be certain what the value of that variable is, you can simply run through the macro pressing F8, and when you want to know the value (at that given time), simply take your mouse over the variable and you will see the value at that point.

Let’s start with this, let me know of course if you have questions or any other excel functions/problems that you would like to have looked into!

***************************************************

Look Good at Work and Become Indispensable Become an Excel Pro and Impress Your Boss


***************************************************

3 Feedbacks on "How To Debug An Excel Macro"

Norman Shepard

I have a problem with VBA, I don’t get what works.
The problem, I have ten values, located on a worksheet, that I need to add together . 3 at a time, and check against a variable , if they are within one of that variable, i need it printed to a cell location. It is that simple, but i can’t get it to work.



jose moreno

Macros very interesant.



SEO services in Mesa

SEO services in Mesa

How To Debug An Excel Macro | Experiments in Finance