Track and write the number of times that sub is run into a cell

M

Max

I'm looking for a way to keep track of the number of times that a sub is run
(via the press of a forms button) and to write that number into a cell on the
sheet, say into G1. If the button is pressed 10x, then G1 will read: 10.
Thanks
 
O

ozgrid.com

Sub MyMacro()
If Application.Caller = "Button 1" Then
Sheet1.Range("G1") = Sheet1.Range("G1") + 1
End If

'YOUR CODE
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top