Enable Events

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,099
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
In Userform Activate two combo box values are set, but I don't want their change events to fire.
So I put

Code:
Application.Enable Events = False
before setting the combo box text value.

But the change event runs regardless.

Isn't Enable Events = False meant to prevent that ?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
In Userform Activate two combo box values are set, but I don't want their change events to fire.
So I put

Code:
Application.Enable Events = False
before setting the combo box text value.


But the change event runs regardless.

Isn't Enable Events = False meant to prevent that ?

Try it without the space between Enable and Events.
 
Upvote 0
Sorry that was me typing into the message. It's correct in the code module.
I forced it to work with my own boolean, but don't get why I needed to.
 
Upvote 0
Neither do I. Application.EnableEvents should turn off the event trigger, but not seeing the full code, I wouldn't have a clue.
regards, JLG
 
Upvote 0
Not much code to see, just a couple of Combo Boxes and their Change event. Be interested if it *did* work.
After looking deeper it may affect Worksheet Controls only.
 
Upvote 0
EnableEvents does not work with userform controls.
You will need to build your own event handler, or change the code to use as Combo_Click event rather than a combo_Change event.
 
Upvote 0
I forced it to work with my own boolean, but don't get why I needed to.

And from that webpage: ``Application.EnableEvents does not apply to controls on a UserForm. [....] To suppress events in a form, you can create a variable at the form's module level called "EnableEvents" and set that to False before changing a property that will cause an event to be raised``.

Sounds like exactly what Alexander did. Give the man some credit. Clever guy!

PS.... In my Unix days, we used to say ``don't ask why``. (wink)
 
Upvote 0
Chip Pearson's website is one of the best for insight into how vba works and how to get around the quirks of MS applications.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top