Consulting

Results 1 to 4 of 4

Thread: Solved: How can I prevent Button Double clicks?

  1. #1
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location

    Solved: How can I prevent Button Double clicks?

    I need some code that I can add to all of my forms type sheet buttons, that will prevent quick multiple clicks from running the routine multiple times. Possibly a timer if necessary, that will require waiting at least one or two seconds before clicking again. – Something simple, short and sweet, and generic, so that I can use it for most code situations within the button’s assigned macro.

    For testing purposes I've attached a sample workbook that has the simplistic macro example shown below, assigned to a button.

    Thanks

    [vba]
    Sub Macro1()
    With ActiveCell
    With .Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    .Offset(1, 0).Select
    End With
    End Sub

    [/vba]
    Attached Files Attached Files

  2. #2
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    bump...

    hope you don't mind. I'm just am little desperate as I have one procedure for an app. currently in use at my work, that falls down big time if the code runs twice in quick succession by accidentally double clicking the button.

    Thanks

  3. #3
    VBAX Regular
    Joined
    Nov 2011
    Location
    Ufa
    Posts
    75
    Location
    Maybe something like this
    [vba]Sub Macro1()
    Dim shp As Shape
    Set shp = ActiveSheet.Shapes(1)
    shp.Visible = msoFalse

    With ActiveCell
    .Interior.ColorIndex = 6
    .Offset(1).Select
    End With

    ' here your procedure is working
    shp.Visible = msoTrue 'this line is inserted at the end of your procedure
    End Sub[/vba]

  4. #4
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    HI nilem,

    Nice thinking.. Works well.

    Thanks

Posting Permissions

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