An implementation of Visual Basic that is built into Microsoft products.
Hi, SteveD
Your gRunCount keeps its value because it is a module-level variable, and those normally stay alive until Word stops running the code or the project gets reset.
So the easiest fix is just to cycle it back to 1 after 3:
Sub OneButtonMacro()End Sub
gRunCount = (gRunCount Mod 3) + 1
ProcessSelection gRunCount
That will make it go 1, 2, 3, then back to 1 every time you press the button.
If you prefer to keep your Select Case, then just reset the counter after the third run instead of locking it at 3:
Case 3
ProcessSelection 3
gRunCount = 0
``
Then the next press starts again at 1.
If you ever want the number to be remembered even after closing and reopening the document, it is recommended that you store it in a Word document variable instead, because document variables are meant to preserve macro settings between sessions.
Thank you for your patience in reading, I hope this information has been helpful to you.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment."
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.