Time limit for a userform

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi
Is there a way to limit the time a userform is up?
Not all users can see or know about the "X" in the userform to unload it.
I thought about adding a command button to "close" but I'm wondering if I can add a code to the macro
I'm onlky using 1 sheet in the workbook
VBA Code:
Private Sub Workbook_Open()
Range("A1").Select
UserForm2.Show
End Sub

mike
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
MIke

You could use Application.OnTime to call a sub that unloads the userform

That code could go in the Initialize event of the userform.
VBA Code:
Private Sub UserForm_Initialize()
     ' close form after 10 minutes
    Application.OnTime Now + TimeSerial(10, 0, 0), "UnloadForm"
End Sub
The UnloadForm code would go in a standard module.

VBA Code:
Sub UnloadForm()
    Unload UserForm1
End Sub
If you took this approach you might need to consider some other factors.

For example,what should happen if the user interacts with the userform in the 10 minute period?

Should the timer be 'reset'?

What about saving data?
 
Upvote 0
Solution
Hi Norie
I never thought about your questions about if the user is doing input and the time limit is up
See, that's why you get the big money :)
I'll add the command button to close for now
Thanks for your help

mike
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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