+ Reply to Thread
Results 1 to 4 of 4

Application.EnableEvents = FALSE not working

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    Maryland, United Stated
    MS-Off Ver
    Excel 2007
    Posts
    1

    Application.EnableEvents = FALSE not working

    Hi all,

    I have the following code in my workbook:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Application.EnableEvents = False
    With Worksheets("Forecast Files")
    .Activate
    .FcstSchool.Value = "School"
    .Range("C3").Select
    ActiveWindow.ScrollColumn = ActiveCell.Column
    ActiveWindow.ScrollRow = ActiveCell.row
    End With
    With Worksheets("Revenue Forecasts")
    .Activate
    .Forecast.Value = "Forecast"
    .School.Value = "School"
    .Range("D3").Select
    ActiveWindow.ScrollColumn = ActiveCell.Column
    ActiveWindow.ScrollRow = ActiveCell.row
    End With
    Application.EnableEvents = True
    End Sub

    During normal use of the workbook, there is a Change event that triggers when FcstSchool is changed, but I do NOT want that to trigger during this save event. I've been using this workbook/code for a couple of years and it's never been an issue, now all of the sudden the Change event is triggering after the highlighted line despite the EnableEvents = False line. Any ideas why this would have changed all of a sudden and how I can get it to work properly again? Thanks!
    Last edited by slane52209; 10-14-2017 at 12:38 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Application.EnableEvents = FALSE not working

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.

    To add a file to a post

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,920

    Re: Application.EnableEvents = FALSE not working

    One solution:
    * Declare a variable, say, SaveAndClose, as Boolean (in a standard module)
    * In the Workbook_BeforeSave module, set it to TRUE
    * In the Worksheet_Change module, test it for TRUE and, if so exit...
    Last edited by protonLeah; 10-14-2017 at 05:57 PM.
    Ben Van Johnson

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Application.EnableEvents = FALSE not working

    Are these ActiveX controls?
    Entia non sunt multiplicanda sine necessitate

+ 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. HELP: VBA not working becaluse of Application.EnableEvents = False
    By oct2mine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2015, 10:27 PM
  2. application.EnableEvents value changing to false
    By oosterhg in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-18-2012, 12:21 PM
  3. When will macro in module run when Application.EnableEvents is set to False?
    By twills in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-2010, 06:14 AM
  4. Application.EnableEvents Changes to False
    By Rushti in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-30-2009, 10:53 AM
  5. preventing Application.EnableEvents = False
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2006, 06:20 AM
  6. Application.EnableEvents = False not working
    By Paul Martin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2005, 12:06 AM
  7. [SOLVED] Problems with BeforeSave and Application.EnableEvents = False
    By Sanne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2005, 09: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