+ Reply to Thread
Results 1 to 6 of 6

VBA workbook_BerforClose iteration

  1. #1
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,217

    VBA workbook_BerforClose iteration

    Please Login or Register  to view this content.
    This code re-enters the Before_Close routine when it executes the ThisWorkbookClose statement so the Msgbox is output again.

    Why ? And can this be avoided ?

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: VBA workbook_BerforClose iteration

    Hi
    Try
    Please Login or Register  to view this content.

  3. #3
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA workbook_BerforClose iteration

    Maybe :
    Please Login or Register  to view this content.
    ThisWorkbook.Close method will raise Workbook_BeforeClose event, unless Application.EnableEvents is set to false (as in mohadin's code).
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: VBA workbook_BerforClose iteration

    All you need to do in the 2nd case is Me.Save. No need to use Application.EnableEvents.

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: VBA workbook_BerforClose iteration

    Reduced to essentials,

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,217

    Re: VBA workbook_BerforClose iteration

    Both solutions work.

    Thank you for your help.

+ 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. Run an entire loop instead of iteration by iteration when stepping into code?
    By Norcal1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2019, 04:20 PM
  2. Iteration within iteration
    By shamsul in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-04-2016, 07:09 PM
  3. [SOLVED] Iteration Help
    By devos in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-10-2014, 07:30 PM
  4. Iteration
    By StillLearning2 in forum Excel General
    Replies: 2
    Last Post: 02-10-2009, 02:06 PM
  5. [SOLVED] Need help with iteration
    By Ron M. in forum Excel General
    Replies: 7
    Last Post: 03-13-2006, 08:35 PM
  6. Iteration
    By M. Homayon in forum Excel General
    Replies: 1
    Last Post: 01-10-2006, 09:10 PM
  7. [SOLVED] Iteration
    By Jan in forum Excel General
    Replies: 1
    Last Post: 01-10-2006, 07:15 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