Switch betwen Excel Sheets so many X seconds?

sentinelace

New Member
Joined
Nov 11, 2010
Messages
9
I have a spreadsheet that runs 24/7 monitor and the cells automatically update. I need to add a new sheet to the workbook. My question is, How can I set the spreadsheet to switch between the different sheets every so many seconds?
 
Re: Switch between Excel Sheets so many X seconds?

Hello Ruddles:

if I use the following code and add the word "visible" next to "For Each ws" would that run the macro for the visible sheets only? or would it also run it for the hidden ones?


Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub pause()
Dim pause As Worksheet
Do
For Each pause In ThisWorkbook.Worksheets
pause.Activate
Application.Wait Now + TimeValue("00:00:15")
End Sub

Public Sub Switch()

Dim ws As Worksheet

Do
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Application.Wait Now() + TimeValue("00:00:15")
If GetAsyncKeyState(vbKeyShift) Then Exit Sub
DoEvents
Next ws
Loop

End Sub

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:00:15"), "ThisWorkbook.Switch"
End Sub


Thank You!
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Re: Switch between Excel Sheets so many X seconds?

No, you would need to test the .Visible property of the worksheet:-
Code:
If ws.Visible = True Then
[COLOR=#008000]   ' do what you need to do for visible worksheet[/COLOR]
End If
 
Last edited:
Upvote 0
Re: Switch between Excel Sheets so many X seconds?

Hi All,

I am using the below code to switch the worksheet. I noticed when I started the marco, for the first page it will always lag.
the table of my first page will only show half only and after a 7 seconds, it will show second half of the table and the first half of the table will disappear.
How can I fix this issue? I have a total of 20 ws in this file and there are 3 hidden ws which I do not want to display.
Thanks!
 
Upvote 0
Re: Switch between Excel Sheets so many X seconds?

Hi All,

I am using the below code to switch the worksheet. I noticed when I started the marco, for the first page it will always lag.
the table of my first page will only show half only and after a 7 seconds, it will show second half of the table and the first half of the table will disappear.
How can I fix this issue? I have a total of 20 ws in this file and there are 3 hidden ws which I do not want to display.
Thanks!

Sorry the code I am using is this:

Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Public Sub Switch()

Dim ws As Worksheet

Do
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Application.Wait Now() + TimeValue("00:00:07")
If GetAsyncKeyState(vbKeyShift) Then Exit Sub
DoEvents
Next ws
Loop

End Sub
Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:00:07"), "ThisWorkbook.Switch"
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,091
Messages
6,128,779
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top