Share via

form control button count

Anonymous
2015-10-02T18:41:57+00:00

I have several form control buttons on my worksheet and I would like to count how many times each one is pressed individually and display the number in a adjacent cell to be used in another calculation.

Any help greatly apreciated

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2015-10-02T19:37:38+00:00

Are the buttons each contained within a cell?

And do you want the count to be displayed in the cell to the right of the respective button?

If so, try the following...

  1. For the macro or macros assigned to your buttons, add the following line of code at the end...

Call IncrementButtonCount

  1. Add the following code in the same module...

Private Sub IncrementButtonCount()

    With ActiveSheet.Buttons(Application.Caller).TopLeftCell.Offset(, 1)

        .Value = .Value + 1

    End With

End Sub

Hope this helps!

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-10-02T20:19:29+00:00

    Thank you for the help Gord.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-10-02T20:17:16+00:00

    Thank you for this works perfectly.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-10-02T19:10:40+00:00

    Sub Button1_Click()

    With ActiveSheet

       .Range("A1").Value = _

       .Range("A1").Value + 1

    End With

    MsgBox "you pressed the button"

    'your code goes here

    End Sub

    Gord

    Was this answer helpful?

    0 comments No comments