Loop Through Worksheet

ps1

Board Regular
Joined
Aug 21, 2010
Messages
89
Hi all,

Hope someone can help. Is it possible to have some sort of vb/macro code to scroll through 2 particular worksheets and display 1 worksheet for a set period then the other, have that on loop and then if say the key 'x' is pressed stop the macro?

What I am in the process of building is a reporting board, and performance related board but wish to show both of these on our widescreen TV.

All help appreciated thanks.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This is a very simple piece of code which you can incorporate fairly easily into a longer program if necessary:-
Code:
Option Explicit
 
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Public Sub SwitchSheets()
 
  Do
 
    Sheets("[B][COLOR=red]Sheet1[/COLOR][/B]").Activate
    Application.Wait Now() + TimeValue("[COLOR=red][B]00:00:05[/B][/COLOR]")
 
    Sheets("[B][COLOR=red]Sheet2[/COLOR][/B]").Activate
    Application.Wait Now() + TimeValue("[COLOR=red][B]00:00:05[/B][/COLOR]")
 
    If GetAsyncKeyState(vbKeyShift) Then Exit Sub
 
  Loop
 
End Sub
Paste into a general code module and change the bits in red to suit. It stops when you hit the Shift key.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,814
Members
452,945
Latest member
Bib195

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