NiklasNordkvist
New Member
- Joined
- Jan 5, 2023
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hello!
I have one button for starting the macro but I also want a button to stop the macro for running completely.
I don´t know how to type this, hope someone can help me out:
Here is the code I have:
I have one button for starting the macro but I also want a button to stop the macro for running completely.
I don´t know how to type this, hope someone can help me out:
Here is the code I have:
VBA Code:
Sub TabShow()
Dim i As Integer
Dim Pause As Double
Pause = 5 'Pause delay in seconds
Loops = 1 'How many loops do you want to do
While Loops
For i = 1 To Worksheets.Count
If Worksheets(i).Visible Then 'Checks for Hidden worksheets and skips if hidden
Worksheets(i).Activate 'Select the next worksheet
x = Timer
While Timer - x < Pause 'This does the pausing
DoEvents: DoEvents
Wend
End If
Next i
Wend
End Sub