What's going on?

JohnLee

Board Regular
Joined
Oct 24, 2006
Messages
80
Driving me nuts!!

I have a bit of code that changes the value of a combobox on a form - BUT the combobox has a ComboBox1_Change() macro assigned which I do not want to be executed when changed by the VBA code, only when amended by the user on the associated form.

I thought I could just have bit of code like:

Code:
. . . .
Application.EnableEvents = False
Me.ComboBox1.Value = "A"
Application.EnableEvents = True
. . . .

and the event macro invoked by the change in value would not be invoked. But oh no! It invokes the ComboBox1_Change macro regardless! Am I asking the impossible, and if so what exactly is the EnableEvents property then used for?

Thanks in anticipation!!

John
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
you could have a boolean variable which when you start your code you set it to false and then at the end of the code you set it to true. (or which ever way you want) Then inside the changed event put an IF statement saying "If boolean_variable = False then don't run the code"(which would be the condition if you were changing the combox from VBA)
 
Upvote 0

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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