+ Reply to Thread
Results 1 to 6 of 6

Strange Debugger behavior

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Strange Debugger behavior

    I'm getting some weird behavior when trying to debug some VBA code. One problem is that whenever I get a run-time error, I only get the "OK" and "Help" buttons. The "Debug" button doesn't even show up, so I have no idea what code caused the error.

    Another problem is I can only partially run the debugger when stepping and using breakpoints. I am able to step through the code and also run to breakpoints, but once I step into an Application function, like Application.InputBox, I seem to get ejected from the Debugger. The code takes off from that point as if I hit F5.

    I'm not a regular VBA programmer but have written a bit of code in the past with nothing like this. However, this is the first time I get back into coding after upgrading from Windows 7 to 10. Would that make a difference? We also may have upgraded to Office Professional Plus 2016 during that time, but I'm not sure about that.

    Thanks for any thoughts on this.

    --Marc

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Strange Debugger behavior

    The Debug button does not appear certain types of errors, but if you are in Developer mode on the ribbon, you can just click 'Visual Basic' on the menu bar and it opens the editor.

    When you are stepping through and hit one of the lines that say "Can't enter break mode" you can then set a break point after that line and it will allow you to resume a line by line step through.

    The vb editor has not had a lot of enhancement over the years, so you just have to understand its quirks and work around them.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Strange Debugger behavior

    Thanks, JLGWhiz, but that's not the behavior I'm seeing. I'm already in the VB editor and executing the code using F5 or stepping with F8. What has happened in the past is when I run into a run-time error, I would get the error popup that gives the options, "OK", "Debug", and "Help". I would then hit the Debug button and the offending line of code is highlighted in the editor. I no longer get the Debug option, so I no longer know which line caused the error..

    ErrorCapture.PNG

    And when I'm stepping through, I don't get the "Can't enter break mode" message. What happens is the code steps fine into the Application.InputBox, where I am able to enter the info I'm asking for in the box. But when I click on "OK", the macro just keeps on executing, not stepping. But I think I've got this one figured out.

    I'm using some basic error handling to take care of canceling the box. I've got:
    Please Login or Register  to view this content.
    That's where I get kicked out of the debugger. I removed the "On Error..." statements and it steps through that just fine. I don't remember this happening before, but I can't be certain I tried to step through any "On Error" code.

    Just to make sure, I also ran one of my older macros and it's now exhibiting the same behavior. I was hoping there was some setting in the workbook or macro itself, but it appears to be something different with Excel itself.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Strange Debugger behavior

    The issue is discussed in this link at great length.
    https://www.mrexcel.com/board/thread...1112588/page-5
    The behavior you are describing appears to be normal behavior for the editor. Again, you have to learn to work around the way the editor interrupts the code, or changes from single step to Run. Microsoft does not upgrade the editor to my knowledge. So we all have to learn how to use it as best we can.

  5. #5
    Registered User
    Join Date
    06-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Strange Debugger behavior

    Thanks JLGWhiz. That link had the solution for me: VB Editor->Tools->Options->General->Break on All Errors. It was previously set to Break on Unhandled Errors.

    That not only brought back the Debug button, but also now allows me to now step through On Error... code.

    Have a great day!

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Strange Debugger behavior

    Glad it helped,
    Regards, JLG

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Delete command button results in strange debugger behavior...help!
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-30-2017, 01:59 PM
  2. [SOLVED] AVERAGEIF strange behavior
    By sv3nster in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-05-2014, 08:47 PM
  3. strange calculation behavior
    By rokstedy in forum Excel General
    Replies: 9
    Last Post: 05-04-2011, 03:28 PM
  4. VBA - Strange behavior
    By MVM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2006, 02:50 PM
  5. [SOLVED] Strange TAB behavior
    By m davidson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2006, 01:15 PM
  6. [SOLVED] Strange behavior.
    By Wiley Coyote in forum Excel General
    Replies: 7
    Last Post: 10-18-2005, 12:05 PM
  7. [SOLVED] Strange VBE Behavior
    By Jeff Robson in forum Excel General
    Replies: 4
    Last Post: 01-14-2005, 07:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1