Results 1 to 4 of 4

BeforeClose code working in debug but sporadically in actual execution - how can I test it

Threaded View

  1. #4
    Registered User
    Join Date
    09-03-2014
    Location
    Columbus, OH
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: BeforeClose code working in debug but sporadically in actual execution - how can I tes

    GeneralDisarray - yes, if I step through the code completely it does all of the coded deletions and other pieces with no issues. I can stop just about anywhere and step through it (I've tried just about every stop point I can think of) and then let it run past that point (F5) and it will work as designed. It will also work as designed if I F8 through every single step (uber tedious but I had to do it to be sure!)

    AlphaFrog - I feel like I'm responding to a celebrity I see your name here so often in my searches! I thought that since the userform was in the correct workbook that it would force the active workbook to be the correct one but I can certainly change that to make it safer.

    bDoNotRun was my best guess as to the culprit as well but I don't think I've tested it/debugged it thoroughly so it's well worth another look. I declare it as a Public function in my function module (just a regular module - I named a module for functions, one for main code and one for just admin stuff/testing)

    Public bCancelClose As Boolean 'Used in BeforeClose with the Cancel button
    Public bDoNotRun As Boolean 'Used in SetDoNotRun function to bypass BeforeClose code when needed
    Option Explicit
    I'll watch bDoNotRun and see if anything funky is happening there and then report back.

    Thank you both VERY much for trudging through that code!
    Last edited by lorikgator; 11-19-2015 at 03:08 PM. Reason: Fixed code wrapper

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Problems with BeforeClose Event code
    By tmbarnard in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-03-2015, 06:05 PM
  2. [SOLVED] BeforeClose event not running/working when file is closed through VBA in another file
    By jaimelwilson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2014, 03:43 AM
  3. VBA Code Runs in Debug Mode But Returns Type Mismatch Error Outside Debug Mode
    By valerie.k.chiang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2014, 03:48 PM
  4. [SOLVED] Debug: How to debug this code?
    By reach78 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-25-2013, 07:16 AM
  5. VLOOKUP returning #N/A sporadically
    By Bobbo Jones in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-13-2013, 10:15 PM
  6. Beforeclose sub suddenly stopped working
    By cuewoz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2010, 12:29 PM
  7. Shared Workbook updating sporadically
    By Maddman in forum Excel General
    Replies: 1
    Last Post: 02-28-2005, 10:06 AM

Tags for this Thread

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