D
Derek Gadd
Hi,
I'm having trouble getting a couple of things to work properly -
Application.EnableEvents and Application.DisplayAlerts. I assume the
two problems are related but I don't know the cause.
For the EnableEvents:
I have two comboboxes on a spreadsheet. When the first one is changed
by the user, it updates the contents of the second combobox. This
procedure ends by calling a procedure (FilterSub) that is also run
when the second box is updated by the user. This procedure filters
some data and cuts and pastes it to a worksheet. To prevent automatic
updates of the second combobox causing the second procedure to run
twice, I have set Application.EnableEvents = False. However, it still
runs twice and I can't figure out why! It starts running the change
event at the line indicated below:
Sub FillCombo(Category As Collection, MyCombo As MSForms.ComboBox)
Application.EnableEvents = False
Dim Item
With MyCombo
.Clear 'The following procedure runs after this -I don't want
it to!
.AddItem "<All>"
For Each Item In Category
If Item <> "" Then .AddItem Item
Next Item
.ListIndex = 0
End With
End Sub
Application.EnableEvents is still set to false when the following code
runs:
Private Sub ComboBox2_Change()
FilterSub
End Sub
Am I using the EnableEvents property for the wrong thing?
For DisplayAlerts:
Before closing I have this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
End Sub
but it still asks if I want to save. I've also tried
adding/substituting ActiveWorkbook.Saved = True but it still doesn't
work.
Can anybody help? I'm using Office 2000.
TIA,
Derek
I'm having trouble getting a couple of things to work properly -
Application.EnableEvents and Application.DisplayAlerts. I assume the
two problems are related but I don't know the cause.
For the EnableEvents:
I have two comboboxes on a spreadsheet. When the first one is changed
by the user, it updates the contents of the second combobox. This
procedure ends by calling a procedure (FilterSub) that is also run
when the second box is updated by the user. This procedure filters
some data and cuts and pastes it to a worksheet. To prevent automatic
updates of the second combobox causing the second procedure to run
twice, I have set Application.EnableEvents = False. However, it still
runs twice and I can't figure out why! It starts running the change
event at the line indicated below:
Sub FillCombo(Category As Collection, MyCombo As MSForms.ComboBox)
Application.EnableEvents = False
Dim Item
With MyCombo
.Clear 'The following procedure runs after this -I don't want
it to!
.AddItem "<All>"
For Each Item In Category
If Item <> "" Then .AddItem Item
Next Item
.ListIndex = 0
End With
End Sub
Application.EnableEvents is still set to false when the following code
runs:
Private Sub ComboBox2_Change()
FilterSub
End Sub
Am I using the EnableEvents property for the wrong thing?
For DisplayAlerts:
Before closing I have this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
End Sub
but it still asks if I want to save. I've also tried
adding/substituting ActiveWorkbook.Saved = True but it still doesn't
work.
Can anybody help? I'm using Office 2000.
TIA,
Derek