Userform Timed with Timer Cancellation Button.

fben96

New Member
Joined
Jul 30, 2018
Messages
15
I have a timer once my workbook opens, after one minute aUserform pops up, and asks if you are still using the file. If you hit yes, theoriginal timer resets but if you hit no the workbook closes. However, when theuserform pops up a second timer starts, when this timer times out it closes theworkbook. I would like for the second timer to be cancelled if the user clicksyes in the userform. Here is my code. Thus far.

HTML:
Sub Start_Time()
Application.OnTime Now + TimeValue("00:01:00"), "Time_Form"
End Sub
Sub Time_Form()
TimerForm.Show vbModeless
End Sub
Sub Closeout()
Application.DisplayAlerts = True
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

this is the code for the userfom

HTML:
Private Sub NoButton_Click()
Call Closeout
End Sub
Private Sub UserForm_Initialize()
Application.OnTime Now + TimeValue("00:01:00"), "Closeout"
End Sub
Private Sub YesButton_Click()
Unload Me
Application.OnTime Now + TimeValue("00:01:00"), "Start_Time"
IsNull (Ln = 8)
End Sub


 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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