Results 1 to 12 of 12

Thread: [RESOLVED] VBA Debugger Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Resolved [RESOLVED] VBA Debugger Question

    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?

    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.
    Last edited by Torc; Jul 14th, 2006 at 11:11 AM.
    Signature Under Construction

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Debugger Question

    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

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: VBA Debugger Question

    Or just set a breakpoint. Click in the left margin to set it, click again to remove it.
    Tengo mas preguntas que contestas

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: VBA Debugger Question

    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.
    Signature Under Construction

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: VBA Debugger Question

    If you don't have a breakpoint or stop anywhere in the module, why would it stop there?
    Tengo mas preguntas que contestas

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: VBA Debugger Question

    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.
    Signature Under Construction

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VBA Debugger Question

    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'.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: VBA Debugger Question

    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
    Signature Under Construction

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VBA Debugger Question

    Try it inside the VB editor (where the code runs), rather than in Excel itself.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: VBA Debugger Question

    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.
    Signature Under Construction

  11. #11
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: VBA Debugger Question

    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?
    Tengo mas preguntas que contestas

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: VBA Debugger Question

    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..
    Signature Under Construction

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width