View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Intellihome[_34_] Intellihome[_34_] is offline
external usenet poster
 
Posts: 1
Default TO Bug or Not TO Bug? That is the question.


Hello everyone,

I just wanted to draw your attention to how Excel EnableEvents handle
events for ComboBoxes. So far I have not seen any solution on to how t
turn off handling procedures for ComboBoxes.

Here is the code, I put dashes to keep the formatting, because
Code
-------------------
tags do not work.

- Private Sub Worksheet_Deactivate() 'Sub Worksheet_Change(ByVal Target As Range)
------ On Error GoTo Error_handling

---------With Application

-------------.CalculateFull
-------------.Calculation = xlCalculationManual
-------------.ScreenUpdating = False
-------------.EnableEvents = False

-------------With Sheets("Results (Average)")
------------------.ComboBox1.Value = 0
------------------.ComboBox1.ListFillRange = list
-------------End With '<<< after this line change event would be fired twice, because ComboBox was changed twice :(

---------End With

- Error_handling:


- Application.Calculation = xlCalculationAutomatic
- Application.ScreenUpdating = True
- Application.EnableEvents = True

End Sub

and so on.

The problem bacomes very significant, when you have lets say 10 comboboxes in the workbook and for each you have to make 10 changes, and then may be do it several times in different procedures. So 10x10xN would be 100xN. So if your N is 10 it adds 1000 extra checkings - IF YOU HAVE A GLOBAL VARIABLE THAT FLAGS IT, other wise it adds 1000 of executions of the handling procedures, which you don't even need.

Any ideas would be VERY MUCH APPRECIATED!!!

Iva

--
Intellihom
-----------------------------------------------------------------------
Intellihome's Profile: http://www.msusenet.com/member.php?userid=147
View this thread: http://www.msusenet.com/t-187057718