Indexing Worksheets for a set viewing time

Eire75

New Member
Joined
Feb 23, 2008
Messages
19
Hi,

I would like to write some code which will allow me to display each worksheet (9 in total) in a workbook for a set time (perhaps 10 minutes per worksheet) and when finished, iterate the process again indefinitely. I have some code which refreshes the data in each worksheet already and so would like to incorporate both sets of code into a single macro.

The end result will be 9 sets of continuously updated data which will be displayed on a large screen, to be used for process monitoring.

Any help would be greatly appreciated.

Eire.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Something along these lines:-
Code:
Sub Carousel()
 
  Dim ws As Worksheet
  
  Do
    For Each ws In ThisWorkbook.Worksheets
      ws.Activate
      Application.Wait Now() + TimeValue("00:00:03")
      DoEvents
    Next ws
  Loop

End Sub
I've set the pause to three seconds for testing purposes but you'd change the value to whatever you wanted.
 
Upvote 0
Hi Ruddles,

Your code works perfectly, thanks very much for the help.

One other thing - is it possible to index through certain worksheets only? I have ten worksheets, two of which will be hidden. When I run the macro, I would like to wait the 3 seconds (or probably 10 seconds) on the remaining 8 worksheets only. As it is, it still waits for each duration, even on the hidden worksheets. Not a big problem but it would be tidier if I could achieve this.

Thanks again,

Eire75
 
Upvote 0
You need to test the .Visible property of each sheet and only display and pause for sheets which aren't hidden:-
Code:
Sub Carousel()
 
  Dim ws As Worksheet
 
  Do
    For Each ws In ThisWorkbook.Worksheets
      If ws.Visible = True Then
        ws.Activate
        Application.Wait Now() + TimeValue("00:00:03")
      End If
      DoEvents
    Next ws
  Loop
 
End Sub

You could also extend the test to include or exclude sheets depending on other properties such as their names:-
Code:
      If ws.Visible = True And ws.Name <> "DoNotShow" Then
That would show all unhidden sheets except the sheet named DoNotShow.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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