sentinelace
New Member
- Joined
- Nov 11, 2010
- Messages
- 9
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
If Sh.Name = sh1.Name Then
Application.Wait Time + TimeSerial(0, 0, 2)
sh2.Activate
End If
If Sh.Name = sh2.Name Then
Application.Wait Time + TimeSerial(0, 0, 2)
sh1.Activate
End If
End Sub
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:05")
If GetAsyncKeyState(vbKeyShift) Then Exit Sub
DoEvents
Next ws
Loop
End Sub
I like to tell people, "If you can describe what you want in words, a programmer can make the computer do it".
So the question is: which selection of pages do you want to cycle through? How does VBA know which pages you want to display? Is it something in the name of the worksheet? Is it something in the worksheet itself which VBA can use to decide? Or will you supply the programmer with a list of the worksheet names somehow - maybe hard-coded in the VBA or maybe listed in a separate worksheet?
Lets say I have 10 worksheets and all are named differently and i want to display only a "selection" of those worksheets by name ....I used the code below to cycle through the sheets and it works fine... but there is a pause at the end of the cycle which i timed and if you consider the time per page for all my pages both view able and hidden it is pausing for the correct amount it should give if those hidden pages were able to be seen.