Consulting

Results 1 to 2 of 2

Thread: cancel button click events

  1. #1

    cancel button click events

    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.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    I didn't look at your code but it might be easier to use a Control Toolbox button.
    [VBA]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
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •