PDA

Click to See Complete Forum and Search --> : [RESOLVED] VBA Debugger Question


Torc
Jul 14th, 2006, 03:28 AM
In a compiler I used for another programming language it was possible to set
a module so that it was "skipped" by the debugger.

This was most useful when developing a project as I was able to avoid
working through code in the debugger which I had already cleared and
verified, thus allowing me to concentrate on the main code of the project.

Is it possible to do the same in VBA? :confused:

Whenever I work on a project I usually have a number of Subs and functions
which do simple tasks, usually only used in the one project, which I keep having to step through in the Debugger. I dislike having to use Run to Cursor
each time this happens. :eek2:

westconn1
Jul 14th, 2006, 06:17 AM
you can put a stop command in your code, before the code you want to step through, then run to the stop command and step through from there, just remember to remove the stop command when finished debugging.

pete

salvelinus
Jul 14th, 2006, 06:27 AM
Or just set a breakpoint. Click in the left margin to set it, click again to remove it.

Torc
Jul 14th, 2006, 08:56 AM
Use both those methods at the moment, trouble is they are both clumsy.

I was hopeing there was some obscure command, flag or trick to get the debugger to run through the code in a module automatically.

salvelinus
Jul 14th, 2006, 09:59 AM
If you don't have a breakpoint or stop anywhere in the module, why would it stop there?

Torc
Jul 14th, 2006, 10:06 AM
The point is that I have Modules in which I have code that I know is fine, but when I am running the debugger I have to go through the code in the debugger.

At present the only way to get past the code without stepping through each line
is to use Run to Cursor, putting the cursor on the last line of the Sub or Function;
or to use Breakpoints and just use Run when I enter one of the modules Subs/Functions.

Unfortunately these are not full satisfactory methods as they tend to have problems if
you where to use Exit Sub or Exit Function.

Which is why I was wondering if there was a way to make a Module hidden/transparent to the debugger so that when the program flow enters one of the
subs or functions it runs without displaying on the debugger.

si_the_geek
Jul 14th, 2006, 10:27 AM
Go to "View" - "Toolbars", and tick "Debug". This will add a new toolbar which contains several icons, including "Step Into", "Step Over", and "Step Out".

If you press "Step Over" on a line which calls another sub, the other sub will run without 'stepping'.

If you press "Step Out", the rest of the current sub will run without 'stepping'.

Torc
Jul 14th, 2006, 10:35 AM
Hmm, Might have known it would be something I cannot use.

I am using Excel 2002 SP3 at work, and it does not have Debug as one of the Toolbars.

I am presented with :- Standard, Formatting, Borders, Chart, Control Toolbox,
Drawing, External Data, Forms, Formula Auditing, Picture, Pivot Table,
Protection, Reviewing, Task Pane, Text to Speech, Visual Basic,
Watch Window, Web & WordArt

si_the_geek
Jul 14th, 2006, 10:45 AM
Try it inside the VB editor (where the code runs), rather than in Excel itself. ;)

Torc
Jul 14th, 2006, 11:10 AM
Great, not the solution I would like, spoilt from using a decent Modula-2 compiler in Poly. But at least it is better than stepping through, or using Run to Cursor.

Thanks.

salvelinus
Jul 14th, 2006, 04:17 PM
I'm glad you found some sort of solution, but I still don't see why it matters if your code runs through the not-to-be-tested module as long as it doesn't stop there. Does that module take a long time to run?

Torc
Jul 17th, 2006, 03:32 AM
Some of the Subs in the modules involve very repetitive work, which can, when running through in Debugger greatly increase the running time of the code.

In some cases I might have a sub which would be called 30 or 40 times, or more.

Constantly trying to use Run to Cursor each time it was called was difficult, especially as the part where the macro was failing was in the calculations around that sub, and I could not use a run until condition as the macro seemed to be failing at different points depending on the data I used..