ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sheet cycle macro (https://www.excelbanter.com/excel-programming/443621-sheet-cycle-macro.html)

John S.[_4_]

sheet cycle macro
 
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

Jim Cone[_2_]

sheet cycle macro
 
See response to your duplicate post in microsoft.public.excel.
--
Jim Cone
Portland, Oregon USA





"John S."
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


All times are GMT +1. The time now is 06:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com