+ Reply to Thread
Results 1 to 9 of 9

Not hitting breakpoints!...

  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    Baltimore Maryland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Not hitting breakpoints!...

    I have breakpoints in a procedure called TestMain() located in Module 22. I call TestMain() from the procedure Worksheet_Change() located in Sheet1. I can hit my breakpoints in Worksheet_Change() but not in TestMain(). Does anyone know why this is?...

    Both Module22 and Sheet are from the project StartChart.xlsm...

    I can run TestMain() via Run->RunSub/UserForms and select TestMain. When I do this I do hit all the breakpoints...

    When I don't hit the breakpoints running form Worksheet_Change(), I know it is running TestMain() do to the MsgBox messages being displayed...

    If anyone has any suggestions I would be most appreciative!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Not hitting breakpoints!...

    Hi cmyers65 and welcome to the forum,

    If your subroutine in Module22 (called TestMain()) was in an if condition in the Private Sub like:
    Please Login or Register  to view this content.
    then TestMain wouldn't be called.

    Another possibility is that the worksheet didn't really change so the Event Code was never called.

    Hope that helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    01-13-2011
    Location
    Baltimore Maryland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Not hitting breakpoints!...

    I've proved I'm getting to the Run command by adding MsgBox calls. I also can see I'm calling the routine because I put a MsgBox call into the called routine. I just DON'T get to stop the code with a breakpoint!!! Here's more detail. I stripped down the code to nothing and it still doesn't run.

    Here's the code:

    In Sheet1(Sheet1):

    Please Login or Register  to view this content.
    I set breakpoint at the 'Run "TryMain()"' line above.

    Module22:

    Please Login or Register  to view this content.
    I set a breakpoint at the 'MsgBox"Here I am in TryMain()"' line above.

    Within Excel I have the spreadsheet up for Tab 1 named Sheet1.
    I edit the Cell at location B1.
    I reach the breakpoint in the Worksheet_Change procedure in Sheet1 at the 'Run "TryMain()"' line.
    I then press F5 to continue running.
    I don't reach the breakpoint in the TryMain procedure in Module22 at the 'MsgBox "Here I am..."' line.
    I do get to the message box and hit ok. I just don't sit at the breakpoint...

    I cross posted to Mr. Excel... Here is the link: http://www.mrexcel.com/forum/showthread.php?t=521170
    Last edited by cmyers65; 01-14-2011 at 03:41 PM. Reason: Added Cross Post Link...

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Not hitting breakpoints!...

    @cmyers, appreciate you're a new member but please note:

    1 - use CODE tags to encase your VBA at all times

    2 - more importantly - if you cross post the same question on other Excel message boards (say MrExcel for ex.) you must provide links

    Please be sure to read & familiarise yourself with the Forum Rules before posting further.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Not hitting breakpoints!...

    Try the below without quote marks instead of Run with quotes

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-14-2011
    Location
    A house, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Not hitting breakpoints!...

    You could try to export and import all your forms, modules and class modules, your code could be corrupt.
    Do it manually or use this tool:
    http://www.appspro.com/Utilities/CodeCleaner.htm

    And in the VBE --> Debug - Compile project.

    I experienced more or less the same this morning, breakpoints not hit, forms unexpectedly closed..

    Add.. Turned out my excel / code went unstable after clicking a checkbox which cleared a text from a bound combobox.
    The combobox had a rowsource (=BRONNEN!GENRNGGlaskleur)
    Private Sub chkGlasFront_Click()
    cmbglas.text = ""
    End Sub

    Clicking the checkbox caused an unload of the form (not intented) / crashed the form and after that breakpoints weren't hit...


    G'luck

    Mike D
    Last edited by Nickneem; 01-14-2011 at 05:30 AM.

  7. #7
    Registered User
    Join Date
    01-13-2011
    Location
    Baltimore Maryland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Thumbs up Re: Not hitting breakpoints!...

    MarvinP, thanks for your input. That did the trick!! I'm reposting your solution so that I can play with code tags. I didn't use them and want to make sure I know how to. Thanks again!

    The solution was this:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-13-2011
    Location
    Baltimore Maryland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Not hitting breakpoints!...

    Do you know why calling TryMain() using the run command makes the breakpoints not work? And why using the call command instead fixes this?

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Not hitting breakpoints!...

    Hi cmyers65, here is my best answer.

    Go into the vba editor and search for RUN and read the section on Application.Run.
    In the remarks it claims:

    You cannot use named arguments with this method. Arguments must be passed by position. Objects passed as arguments to the macro are converted to values (by applying the Value property to the object). This means that you cannot pass objects to macros by using the Run method.

    Somehow I believe the above comes into play while CALL does not.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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