Hello all,
I'm new to VBA. I have a code with couple of modules in it. That code is working on older version of windows and not an latest office 365, I must debug it. Not knowing how to do that. Pls help someone.
Debugging in VBA is a joy compared to many other environments. In the VB Editor (the "VBE"), take a look at the Debug item in the ribbon, and experiment with the options you see there. Some highlights and additions:
1) Hit <F8> to step through your program one statement at a time. Each time you hit <F8>, one statement is highlighted in yellow; that's the statement that will be executed next.
2) You don't have to go slowly through the whole program if you know that the problem you need to solve is somewhere in the middle. Just write a Stop statement in the right place and then run the program normally; when it gets to the Stop statement it'll pause there, and you can start using <F8> to figure out what each statement is doing. Sometimes my Stop statement has to be more complicated, for example
Code:
If ACID = "ARC2359" Then Stop
so it'll get most of the way through the data and stop only when it reaches the record that's botching things up for some reason.
3) While the program is paused, you can mouse over any single variable in the code and it'll display its value in a pop-up. Or you can make sure the "Immediate Window" is displayed (look under View in the ribbon), and in the Immediate window type "?<variable name>".
4) Objects with multiple properties can be viewed in the Watch window (again, look under View). Right-click on the name of an object variable in your code, and select "Add Watch"; it'll start displaying the properties of that object in the Watch window.
There are other cool goodies under the Debug option but this is a good place to start. With patience and these tools, an erring program can be made to give up its secrets.