sheet cycle macro

  • Thread starter Thread starter John S.
  • Start date Start date
J

John S.

I am trying to cycle through some sheets, but when you hit Esc the
sheets cycle quickly until Esc is hit again. I want the macro to end
with just on press of Esc. Any help would be great, thanks.


Sub CycleSheets()

Dim lIndex As Long

Application.EnableCancelKey = xlErrorHandler
On Error GoTo ErrorCleanUp

Do Until test = True
For lIndex = 1 To 3
Sheets(lIndex).Select
Application.Wait Time + TimeValue("00:00:02")
Next lIndex
Loop

ErrorCleanUp:
MsgBox "macro has been paused"
Exit Sub

End Sub
 
See response to your duplicate post in microsoft.public.excel.
--
Jim Cone
Portland, Oregon USA





"John S." <[email protected]>
wrote in message
I am trying to cycle through some sheets, but when you hit Esc the
sheets cycle quickly until Esc is hit again. I want the macro to end
with just on press of Esc. Any help would be great, thanks.


Sub CycleSheets()

Dim lIndex As Long

Application.EnableCancelKey = xlErrorHandler
On Error GoTo ErrorCleanUp

Do Until test = True
For lIndex = 1 To 3
Sheets(lIndex).Select
Application.Wait Time + TimeValue("00:00:02")
Next lIndex
Loop

ErrorCleanUp:
MsgBox "macro has been paused"
Exit Sub

End Sub
 
Back
Top