Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Enable events - what is this

  1. #1
    Join Date
    14th May 2005
    Posts
    155

    Enable events - what is this

    Hi,

    What does enable events do with the code ?

    why should it be used?

    thanks

    geethaGupta

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    8th September 2004
    Location
    Northampton, England
    Posts
    2,863

    Re: Enable events - what is this

    GeethaGupta,

    VB:
    Application.EnableEvents = False 
    
    
    is usually used when you create a macro in the code module for a worksheet, workbook, etc, when the macro is created in response to one of Excel's events (e.g. Worksheet_Change when some one updates the worksheet).

    The code has the effect of telling VBA not to respond to events that occur, so if in the example the worksheet is changed again after that code has been run, the Worksheet_Change event macro will not be run.

    It is usually added in code when you have responded to (say) a change in the worksheet and your program will perform some other actions on the worksheet. If you don't set EnableEvents to False, every time your macro updates the worksheet the Worksheet_Change event macro will start again. This may result in the program doing something unexpected, but even if not it gets horribly complicated trying to work out where the program will go next.

    It is worth noting that when you use this command, you need to explicitly turn on events processing again with
    VB:
    Application.EnableEvents = True 
    
    
    as this is not automatically reset at the end of the program, unlike ScreenUpdating. When developing a program containing these commands, if your program errors after "= False" and you end the program, you will need to manually reset it in the Immediate Pane before the events macros will be triggered again.

    Hope this helps.

    Regards,
    Batman.

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    14th May 2005
    Posts
    155

    Re: Enable events - what is this

    Hi Batman,

    a bit confused.

    Do you mean that if EnableEvents = false , then changes in the workbook will not be done or saved till EnableEvents is made true ?

    thanks
    geethagupta

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    31,718

    Re: Enable events - what is this

    Hi geethagupta

    What Batman's saying is, turning off Events with
    VB:
    Application.EnableEvent=False 
    
    
    will stop any code in any Workbook, or Sheet Event code from firing. This is normally done to prevent Events from firing when other code is running.

    By default EnableEvent=True. After turning them off they can only be turned back on via code
    VB:
    Application.EnableEvent=True 
    
    
    , or by closing and re-opening the Excel Application.

Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Enable Macros
    By Joe Derr in forum EXCEL HELP
    Replies: 9
    Last Post: December 27th, 2006, 08:56
  2. Enable CheckBox
    By abbeville in forum EXCEL HELP
    Replies: 7
    Last Post: February 6th, 2006, 05:06
  3. Auto enable events
    By Phil in forum EXCEL HELP
    Replies: 1
    Last Post: February 19th, 2005, 00:49
  4. Enable Macros
    By DoubleB in forum EXCEL HELP
    Replies: 1
    Last Post: July 15th, 2004, 17:53

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
  •  
porno