I haven't done this in a while so had to work it out as well. I added a bit to show the rows if they were hidden when you pressed the stop button.
Sorry I changed it around a bit to how my brain works
(Back to front normally)
Try the code below
Sorry I can't post the workbook as the site won't let me. I put start & stop buttons on sheet 1, the Start button macro is StartTimer, Stop button is StopTimer
Option Explicit
Public RunWhen As Double
Public Const IntSeconds = 3 ' 3 seconds
Public Const RunWhat = "RotateRows"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, IntSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhat, _
Schedule:=True
End Sub
Sub RotateRows()
If ActiveSheet.Rows("2:3").Hidden = False Then
ActiveSheet.Rows("2:3").Hidden = True
ElseIf ActiveSheet.Rows("2:3").Hidden = True Then
ActiveSheet.Rows("2:3").Hidden = False
End If
StartTimer ' Reschedule the procedure
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhat, _
Schedule:=False
If ActiveSheet.Rows("2:3").Hidden = True Then
ActiveSheet.Rows("2:3").Hidden = False
End If
On Error GoTo 0
End Sub
Bookmarks