I am trying to switch between two routines with a timer. The start works fine however the stoptimer throws a 1004 error. Can anyone point out the obvious (not obvious to me and that's why I am pulling my hair out). Many thanks!
Public activeTimer As Boolean
Public runWhen As Double
Sub rotateRows()
activeTimer = True
If activeTimer = True Then
hideRows
showRows
End If
End Sub
Sub hideRows()
ActiveSheet.Rows("2:3").Hidden = true
Application.OnTime Now() + TimeValue("00:00:03"), "hideRows"
End Sub
Sub showRows()
ActiveSheet.Rows("2:3").Hidden = false
Application.OnTime Now() + TimeValue("00:00:03"), "showRows"
End Sub
Sub stopTimer()
activeTimer = False
runWhen = Now() + TimeValue("00:00:03")
Application.OnTime EarliestTime:=runWhen, Procedure:="rotateRows", Schedule:=False
End Sub
Bookmarks