Stop combobox_click code running when the code changes the value

BrianJones

New Member
Joined
Dec 30, 2009
Messages
1
Hi,

I have several combo boxes with varible lists of data; modifiying combobox1 causes the list in combobox2 to be updated. The problem I have is that when the code from combobox1 updates combobox2 I finish with the line below (this line just makes the combobox2.value equal the first value in its list)

Combobox2.value = combobox2.list(0)

using the code to change the combobox2.value causes the:

sub combobox2_click()

code to run, which bascilly abandons the remaining code in:

sub combobox1_click()

and runs extra code I don't want.


Does anyone know how to stop this code automatically activating so? Afterall I am using the sub *_click and not sub*_change.

Why does changing the value make the code think it has been clicked?

Thanks

Brian
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Put your code between EnableEvents lines.
Use this with care because it is a global setting and while =False stops ANY Excel event.
Rich (BB code):
<CODE>
<CODE>Application.EnableEvents = False</CODE>
<CODE>'- YOUR CODE GOES HERE</CODE>
<CODE>Application.EnableEvents = True</CODE>
 
 


</PRE></CODE>
 

Watch MrExcel Video

Forum statistics

Threads
1,099,045
Messages
5,466,222
Members
406,473
Latest member
Dunno123

This Week's Hot Topics

Top