ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Timed Tab Rotation in one Workbook (https://www.excelbanter.com/excel-programming/292098-timed-tab-rotation-one-workbook.html)

Tysone

Timed Tab Rotation in one Workbook
 
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

Frank Kabel

Timed Tab Rotation in one Workbook
 
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!
--
Regards
Frank Kabel
Frankfurt, Germany

Tysone wrote:
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



Tysone

Timed Tab Rotation in one Workbook
 
Perfect, thanks Frank!

Tyson

"Frank Kabel" wrote in message ...
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!
--
Regards
Frank Kabel
Frankfurt, Germany

Tysone wrote:
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



All times are GMT +1. The time now is 03:59 AM.

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