Tuesday 7 January 2014

How to do stop the auto load of the controls like ComboBox when button event triggerred

My issue is:

Selecting the value form the ComboBox and performing button event, After button event triggered then it will automatically ComboBox value changing with initial value.

Solution:

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.