Timed Tab Rotation in one Workbook

  • Thread starter Thread starter Tysone
  • Start date Start date
T

Tysone

OK, here is what I'm trying to do. I have four tabs (Books, Coffee,
Shoes, Candy) in my workbook and what I want Excel to just flip
through each tab every 15 seconds. Is there a way to do this in a
macro?

Thanks

Tyson
 
Hi Thysone
try the following:
1. Put the following in one of your workbook modules:

Dim Nexttime
Sub Toggle_sheets()
Dim i
Nexttime = Now + TimeValue("00:00:15")
i = ActiveSheet.Index + 1
If i > 4 Then i = 1
ActiveWorkbook.Worksheets(i).Activate
Application.OnTime Nexttime, "Toggle_sheets"
End Sub

Sub StopIt()
Application.OnTime Nexttime, "Toggle_sheets", schedule:=False
ActiveWorkbook.Worksheets(1).Activate
End Sub

2. You can start the toggling with the first macro. The second one
stops it.

Note: You won't be able to do anything meaningful while this macro
runs!
 
Perfect, thanks Frank!

Tyson

Frank Kabel said:
Hi Thysone
try the following:
1. Put the following in one of your workbook modules:

Dim Nexttime
Sub Toggle_sheets()
Dim i
Nexttime = Now + TimeValue("00:00:15")
i = ActiveSheet.Index + 1
If i > 4 Then i = 1
ActiveWorkbook.Worksheets(i).Activate
Application.OnTime Nexttime, "Toggle_sheets"
End Sub

Sub StopIt()
Application.OnTime Nexttime, "Toggle_sheets", schedule:=False
ActiveWorkbook.Worksheets(1).Activate
End Sub

2. You can start the toggling with the first macro. The second one
stops it.

Note: You won't be able to do anything meaningful while this macro
runs!
 
Back
Top