|
Answer» Hello,
PLEASE i want to DISPLAY different information in different excel sheets and project it on a dashboard. Can someone help me with a VB script to automatically switch sheets over a set period of time.
For example: Excel workbook contains 5 sheets; sheet1, sheet2, sheet3, sheet4 & sheet5. The code will automatically switch from sheet1 to sheet2 after 30 seconds.
If an addin or a software can assist me with this situation i will be glad.
Counting on you all!
Thanks.
Here's something basic that will cycle thru 5 sheets, displaying each sheet for 30 seconds.
Code: [Select]Public RunWhen As Double Public Const cRunIntervalSeconds = 30 ' 30 seconds Public Const cRunWhat = "SwitchSheet" ' the name of the sub to call
Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) ' Current time + INTERVAL Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True END Sub
Sub SwitchSheet() Dim SheetNum As Integer SheetNum = Sheets(ActiveSheet.Name).Index ' current sheet number If SheetNum <= 4 Then ' set value to 1 less than max sheets to cycle thru SheetNum = SheetNum + 1 ' increment to next sheet Else SheetNum = 1 End If Worksheets(SheetNum).Activate ' activate next sheet StartTimer ' start timer for next cycle End Sub
|