User Form Application.Wait

cfoye130

Board Regular
Joined
Aug 12, 2008
Messages
84
So I am trying to bring up a userform on open of a workbook that asks if the user wants to run the macro or not.

Pretty easy concept.

However, my issue is that I need this workbook to run automated via windows scheduler. The implications of that are that if this userform displays for ~30 seconds I want it to go away and set a cell that the macro triggers off of to Yes. So.... I thought of this simple code.

Code:
Private Sub NoConfirm_Click()
  Sheet1.Cells(1, 1) = "No"
  Unload Me
End Sub
 
Private Sub UserForm_Activate()
  Application.Wait = (Now + TimeValue("0:00:30"))
  Sheet1.Cells(1, 1) = "Yes"
  Unload Me
End Sub
 
Private Sub YesConfirm_Click()
  Sheet1.Cells(1, 1) = "Yes"
  Unload Me
End Sub

My thought being that if the user does not select yes or no within 30 seconds the form unloads and sets the value automatically. Obviously this doesnt work because as far as I know one can't run 2 macros at the same time which would be what was occuring here if the user clicked yes or no during the "wait."

How could I accomplish this? Any help is greatly appreciated!

Thank you!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi cfoye130,

Use the Application.OnTime method rather than Application.Wait. This way you will be able to do other things and other macros can run until being interrupted when your .OnTime code runs. Be sure to check whether cell A1 has been already set to "No" before setting it to "Yes".

Damon
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,812
Members
452,945
Latest member
Bib195

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