View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Disable Combo Box On_Change Macro

Private sub Combobox1_change()
Dim bGo as boolean
bGo = [cboFlag]
if not bGo exit sub
' current code
End Sub


Have your Addin set the value of the defined name cboFlag

Activesheet.Names("cboFlag").RefersTo:="=False"

at the end of our work
Activesheet.Names("cboFlag").RefersTo:="=True"


For example the macro to alter values in the listfillrange:

Sub CCC()
ActiveWorkbook.Names("cboFlag").RefersTo = "=False"
With Worksheets("Added2")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
End With
For Each Cell In rng
Cell.Value = Int(Rnd() * 15 + 1)
Next
ActiveWorkbook.Names("cboFlag").RefersTo = "=True"

End Sub

--
Regards,
Tom Ogilvy


"Randy" wrote in message
om...
I have a procedure that works out of an .XLA file that makes various
changes to another workbook. In the workbook, there is a combo box
(from the Control Toolbox, not the Forms) that has an "on_change"
macro associated with it.

My dilemma arises from the fact that the XLA file is modifying the
named range that is assigned to the combo box in the ListFillRange
(it's source of data for the drop down list). When this happens,
control passes over the Private Sub ComboBox1_Change() and this
procedure then takes over temporarily. These two procedures conflict
with one another and my main procedure does not run correctly.

What I am trying to do is to simply disable the on change macro from
the combo box. When the XLA file opens the workbook containing the
combo box, I am trying to find a way to disable any macros in this
workbook. I tried to use Application.EnableEvents = False, but this
didn't change anything. The combo box on change macro still ran and
screwed everything up.

Can anybody help?

TIA
Randy Eastland