How to add condition within macro?

E

Eric

Does anyone have any suggestion on how to add condition within macro?
I would like to add coding only run TurnOffPC only after 4 pm
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Sub mycoding
....
....

TurnOffPC;
End Sub


'*******************SHUT DOWN*********************
Sub TurnOffXP()
'shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME
ActiveWorkbook.Save
Application.DisplayAlerts = False
Application.Quit
'//shut down the computer
Shell "shutdown -s -t 02", vbHide
End Sub

Sub TurnOffPC()
Dim Action As Long
ActiveWorkbook.Save
Application.DisplayAlerts = False
'//shut down the computer
Action = ExitWindowsEx(EWX_SHUTDOWN, 0&)
Application.Quit
End Sub
'***************************************************
 
M

Mike H

Eric,

You need to ONTIME method. Change MyMacro to the name of yopur code and it
will run at 4 0 clock

Private Sub Workbook_Open()
Application.OnTime TimeValue("16:00:00"), "MyMacro"
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top