anish.ms
09-16-2021, 09:32 PM
Hi Experts,
The following on time message is not popping up if the user is editing a cell. How can I run the codes even if the user is editing a cell (probably a formula) without loosing the cell value/formula.
Private Sub Workbook_Open()
Application.Run "OnTime"
End Sub
Sub OnTime()
Application.OnTime Now + TimeValue("00:10:00"), "MyMacro1"
End Sub
Sub MyMacro1()
UName = Split(Environ("UserName"), ".")
UName = UName(0)
MsgBox "Hi " & UName & vbNewLine & "You have 20 minutes left to complete the tests, workbook will automatically close in 20 Minutes."
Application.OnTime Now + TimeValue("00:10:00"), "MyMacro2"
End Sub
Sub MyMacro2()
MsgBox "Hi " & UName & vbNewLine & "You have 10 minutes left to complete the tests, workbook will automatically close in 10 Minutes."
Application.OnTime Now + TimeValue("00:10:00"), "CloseMacro"
End Sub
Sub CloseMacro()
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Thanks in advance!
The following on time message is not popping up if the user is editing a cell. How can I run the codes even if the user is editing a cell (probably a formula) without loosing the cell value/formula.
Private Sub Workbook_Open()
Application.Run "OnTime"
End Sub
Sub OnTime()
Application.OnTime Now + TimeValue("00:10:00"), "MyMacro1"
End Sub
Sub MyMacro1()
UName = Split(Environ("UserName"), ".")
UName = UName(0)
MsgBox "Hi " & UName & vbNewLine & "You have 20 minutes left to complete the tests, workbook will automatically close in 20 Minutes."
Application.OnTime Now + TimeValue("00:10:00"), "MyMacro2"
End Sub
Sub MyMacro2()
MsgBox "Hi " & UName & vbNewLine & "You have 10 minutes left to complete the tests, workbook will automatically close in 10 Minutes."
Application.OnTime Now + TimeValue("00:10:00"), "CloseMacro"
End Sub
Sub CloseMacro()
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Thanks in advance!