Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Events firing willy nilly
[Excel2000]
I have a form with a number of comboboxes and listboxes on it. Some of these controls change the values of other controls, causing their events to trigger. I want to stop this in some cases. Has anyone got any suggestions? For example, cmbName is changed, and this changes everything else including cmbType. But cmbType has a macro that I only want to run when cmbType is manually changed, but not when its value is changed by another event. Is it possible to achieve this? TIA Darren |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Events firing willy nilly
You would probably need to set a global flag to determine how the control is
being changed. It could get pretty cumbersome with multiple controls. Here's some untested pseudocode: Dim fSwitch As Boolean Sub cmbName_Change() fSwitch = True 'make changes to cmbType fSwitch = False End Sub Sub cmbType_Change() If fSwitch = True Then Exit Sub 'your code here End Sub You get the idea. -- Vasant "Darren Hill" wrote in message ... [Excel2000] I have a form with a number of comboboxes and listboxes on it. Some of these controls change the values of other controls, causing their events to trigger. I want to stop this in some cases. Has anyone got any suggestions? For example, cmbName is changed, and this changes everything else including cmbType. But cmbType has a macro that I only want to run when cmbType is manually changed, but not when its value is changed by another event. Is it possible to achieve this? TIA Darren |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Events firing willy nilly
Darren,
I don't know of any "disable control events" parameter. One way is to have a global Boolean variable which tells other events whether something's already going on. eg. Private i As Long Private blnExecuting As Boolean Private Sub TextBox1_Change() If blnExecuting Then Exit Sub blnExecuting = True i = i + 1 TextBox2.Text = Left(TextBox1.Text, 1) & i blnExecuting = False End Sub Private Sub TextBox2_Change() If blnExecuting Then Exit Sub blnExecuting = True i = i + 1 TextBox1.Text = Left(TextBox2.Text, 1) & i blnExecuting = False End Sub Rob "Darren Hill" wrote in message ... [Excel2000] I have a form with a number of comboboxes and listboxes on it. Some of these controls change the values of other controls, causing their events to trigger. I want to stop this in some cases. Has anyone got any suggestions? For example, cmbName is changed, and this changes everything else including cmbType. But cmbType has a macro that I only want to run when cmbType is manually changed, but not when its value is changed by another event. Is it possible to achieve this? TIA Darren |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Events firing willy nilly
Thanks Rob and Vasant, I'll try that.
-- Darren |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Events firing willy nilly
Update: thanks again, Vasant and Rob. I've got the global variable method
working - whew! Darren |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to prevent BeforeCloseEvent firing more than once. | Excel Discussion (Misc queries) | |||
How can I test if a Macro if firing? | Excel Worksheet Functions | |||
events? | Excel Discussion (Misc queries) | |||
Workbook.Open Event Procedure not firing | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |