Limit the time viewing a spreadsheet

L

Lynxbci3

I want to make a sheet visible for a certain amount of time (15 mins
then to make it invisible (hidden). Is there a way of building in
timer to a spreadsheet
 
L

LB79

Try the below code unhides and hides Sheet2.

---------------
Paste all into a module
---------------
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
Sheets("Sheet2").Visible = True
TimerSeconds = 900 ' 15 mins in seconds
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub

Sub StopTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
Sheets("Sheet2").Visible = False
End Su
 
G

Gord Dibben

Do you want this for yourself or for other users?

For other users.........the StartTimer code would best be placed into
Workbook_Open code.

And hope that the user(s) do not disable Macros.

Gord Dibben Excel MVP
 
Top