Count and Reset Button Clicks
We can use a Global variable to communicate between the two macros:
Dim IAmTheCount As Integer
Sub FirstButton()
If IsEmpty(IAmTheCount) Then
IAmTheCount = 0
End If
IAmTheCount = IAmTheCount + 1
If IAmTheCount 3 Then Exit Sub
'''''''''''''''''''''''''''''''''''''''''
' your stuff
MsgBox "doing button #1 things"
'''''''''''''''''''''''''''''''''''''''''
End Sub
Sub SecondButton()
IAmTheCount = 0
'''''''''''''''''''''''''''''''''''''''''
' your stuff
MsgBox "doing button #2 stuff"
'''''''''''''''''''''''''''''''''''''''''
End Sub
Once the first macro increments the count to three, it does not proceed.
The second macro clears the counter and allow the first macro to resume.
--
Gary''s Student - gsnu201002
"Arlen" wrote:
Hello Experts.
I have a Yahtzee game with 2 buttons/2 macros.
One button (Roll Dice) rolls the dice (Calculate) and the second button
(Next Player) clears all checkboxes on the sheet.
However, I'd like to know if there's a way to disable the first button after
it's been clicked 3 times, then re-enable it once the second button is
clicked and start the count over...
Please advise.
I thank you for your time.
|