Setting Sheet Preview time (VBA)

Luka_LB

Board Regular
Joined
Nov 14, 2011
Messages
51
Hello guys,

I've got stucked on this

I have three sheets, which i want to be previewed for a period of time that I have set

something like this



so i can set minutes or seconds and vba will display that specific sheet for that specific time

I'll have on sheet auto refreshing VBA for every second, if this can be helpful


thanks in advance and looking for your replies


PS: I'm a beginner in VBA coding so I' would appreciate if you would explain or give me whole code
thanks again
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Luka,

In a VBA module insert the following code:

Code:
Public nSheets As Integer

Sub Recalc()
    Calculate
    Worksheets(nSheets).Select
    nSheets = nSheets Mod Worksheets.Count + 1
    Application.StatusBar = Format(Range("c1").Value, "hh:mm:ss")
    DisplayStatusBar = True
    SetTime
End Sub

Sub SetTime()
    SchedRecalc = Now + TimeValue("00:00:03")
    Application.OnTime SchedRecalc, "Recalc"
End Sub

Sub StopTime()
    On Error Resume Next
    Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
    On Error GoTo 0
End Sub

then in the ThisWorkBook tab insert this code:

Code:
Private Sub Workbook_Activate()
   nSheets = 1
   Recalc
End Sub

Save the spreadsheet and then when you re-open it should show each sheet for 3 seconds - this can be changed be editing the SchedRecalc = Now + TimeValue("00:00:03") line.

Hope this helps.

Regards

Peter
 
Upvote 0
Luka,

I've had another look at this and think you need to use the following macros, which are a slight amendment from those above (the stoptime macro didn't work as expected):

Code:
Public nSheets As Integer

Sub Recalc()
    Calculate
    If nSheets = 0 Then Exit Sub
    Worksheets(nSheets).Select
    nSheets = nSheets Mod Worksheets.Count + 1
    Application.StatusBar = Format(Range("c1").Value, "hh:mm:ss")
    DisplayStatusBar = True
    SetTime
End Sub

Sub SetTime()
    SchedRecalc = Now + TimeValue("00:00:03")
    Application.OnTime SchedRecalc, "Recalc"
End Sub

Sub StopTime()
    On Error Resume Next
    Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
    nSheets = 0
    On Error GoTo 0
End Sub

Regards

Peter
 
Upvote 0
Hi Luka,

Hope this was useful, if it was (or even if it wasn't) it is a courtesy to acknowledge help when offered.

Regards
 
Upvote 0
Hi Luka,

Hope this was useful, if it was (or even if it wasn't) it is a courtesy to acknowledge help when offered.

Regards
I know its been a long time... thank you sir! Never meant to be rude or thankless. Hope you are doing very well in this weird times!
 
Upvote 0
Hi Luka, Appreciated - all well here - just bored with the lack of travel! Hope you and your's are well too.
 
Upvote 0

Forum statistics

Threads
1,216,180
Messages
6,129,339
Members
449,504
Latest member
Alan the procrastinator

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