PDA

View Full Version : Solved: Ontime event



wilg
04-23-2011, 03:42 PM
I'm trying to find code for at opening the workbook if after 1 min sheet("1 Maint").range("a1") <> "ok" then close the workbook without saving..

If within 1 min the cell = "ok" then cancel the timer.

mbarron
04-23-2011, 08:23 PM
In the ThisWorkbook module
Private Sub Workbook_Open()
Application.OnTime Now() + TimeSerial(0, 1, 0), "CheckForOK"
End Sub


In a standard module:

Sub CheckForOk()
If UCase(Sheets("1 Maint").Range("a1")) <> "OK" Then
ThisWorkbook.Close False
End If
End Sub

wilg
04-24-2011, 10:26 AM
Worked perfectly. Thanks.