PDA

View Full Version : cancel button click events



troubles123
09-24-2008, 08:16 AM
I have a button on my excel file. When someone clicks on the button and I run a long process. During this time, I want to disable any events fired from that specific button. For example if user keeps clicking the button multiple times, I would like to just ignore them until I finish running the process.

I tried many suggestions I found on the web
1. Application.EnableEvents = False
2. ActiveSheet.Buttons("Button1").Enable = False

Unfortunately, it looks like if the user clicked on the button 5 times, the event still get processed 5 times.

I have attached a test spreadsheet to this message.
Your help will be greatly appreciated.

Kenneth Hobs
09-24-2008, 08:45 AM
I didn't look at your code but it might be easier to use a Control Toolbox button.
Private Sub CommandButton1_Click()
Dim lng As Long, t1 As Double
CommandButton1.Visible = False
t1 = Timer
For lng = 1 To 10000
Cells(lng, "a").Value = lng
Next lng
MsgBox Timer - t1
CommandButton1.Visible = True
End Sub