+ Reply to Thread
Results 1 to 3 of 3

VBA code not executing fully in save on-exit scenario

  1. #1
    Registered User
    Join Date
    02-18-2015
    Location
    United States
    MS-Off Ver
    2013
    Posts
    25

    VBA code not executing fully in save on-exit scenario

    Hello all,

    Just a quick question to what is wrong with this code. I was able to capture the events of when the code will fully execute and when it won't. Initially I had issues with message boxes displaying values for testing purposes and I realized that when a box is popped up it destroys variable data (need to confirm that this is the case).

    My issue currently is that I have a form that I open it works as long as I don't save it "while closing the file" (confirmation window to save). However if I open the file and then use the save button it will save and work ok sometimes but if I move the selection cell and then close the file and it asks me to save, I hit save and when I open it back it won't work fully and I don't know why, I basically have to click on a different random cell and save the file and my form will execute as intended again.

    Here is my code and the files are also attached for working and non working version.

    The parts where it does not grab the data is on the first Code variable, on the working version I do get values but on the non-working I get an empty result.

    Dock-LogWorking.xlsmDock-LogNotWorking.xlsm

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA code not executing fully in save on-exit scenario

    It would be helpful if you would be specific instead of generic. Tell use exactly what you are doing when you have a problem. What did you open what did you click on what did you enter in a cell etc. etc. etc.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    02-18-2015
    Location
    United States
    MS-Off Ver
    2013
    Posts
    25

    Re: VBA code not executing fully in save on-exit scenario

    So, the following code has a form that has a display feature on both listboxes if certain criteria is met based on user input, then it selects the last entry to get the value of "Code" number, with case statement I called the next letter based on the value of lbCode listbox. The issue I have here is that I sometimes get the Code value from the listbox but sometimes I don't, even if I run the same search criteria without adding anything to the list. This happens when I close the file and open it again and save it on exit dialog, or just sometimes at random. I can't find the root cause, like I said, it works and doesn't sometimes. I sometimes thought that if I ran it from the vba menu it would work but it would also work from the button on the excel file itself.

    Please Login or Register  to view this content.

+ 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. Save Backup File to Different Location On Save and Exit
    By slindfors in forum Excel General
    Replies: 0
    Last Post: 06-16-2015, 09:01 AM
  2. Receiving "enable content" warning after executing "save as" code
    By phbryan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2014, 12:02 PM
  3. [SOLVED] Run-time error '1004' when executing Exit Sub command line
    By Henk Stander in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-29-2014, 02:50 AM
  4. Macro code to automatically save and exit after 2 minutes!
    By Garth2014 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 11:03 PM
  5. [SOLVED] Fully Qualifying Code
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2013, 10:19 AM
  6. [SOLVED] Workbook_Open not fully executing
    By jake.masters in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-09-2012, 12:38 AM
  7. Code for button runs and causes "1004" error on Exit and Save
    By TreePapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2010, 02:02 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