Using the computer's system clock to display a Userform at a future date...

chazrab

Well-known Member
Joined
Oct 21, 2006
Messages
884
Office Version
  1. 365
Platform
  1. Windows
How would you use a computer's clock, a Listbox with times formatted as 5:30 PM and a DT Picker1 to display a userform with previously entered text at a specified date and time in the future ?

Application.wait suspends forms, not closes them; timer functions reside within Excel and do react to real time events when the computer is turned off. However, the computer's system clock keeps reporting a continuous real time date and time 24x7 as long as it is plugged in.

How would you do this ? I am not experienced in using a call to the Windows API, but it sounds like this is the only way - is it? I'd prefer not to go outside of the Excel vba coding confines to do this, but how else ? - code in the Workbook Open method ?

I posted this earlier in a different way with more info, but no responses. Users, MVP's Moderator, anyone ...?
Thanks for anyone's help.
cr
Code:
redundant and more wordy,(my apologies) but a more complete picture:
Applicatation.Wait Now + TimeValue("0:00:00") is rendered useless whenthe computer is turned off...

1 - I created Userform1 has a simple Textbox1 that allows users to enter any text. 

2 - Listbox1's Rowsource would be just a range in col A of Sheet1 with Times such as 5:30 AM in 30 min. increments over a 24 hr period(49 rows in drop down list). 

3 - DTPicker1 allows a user to enter a future date DTPIcker1 = 01/27/2017 and a time, Listbox1.value = 10:00 AM. 

4 - User types some text, clicks an OK button on the Form that unloads it. 

5 - When 10:00 AM on 01/27/2017 arrives, the Userform displays with the previously entered text in Textbox1. This can be then postponed, deleted and changed to suit needs. To anyone's knowledge, has this been done?  

If not, how would you use the Listbox Time in combination with the DTPicker to set the Userform to display at the specified future day and time. ? 

Application.wait just SUSPENDS not CLOSES the form, so I don't think it would work here.
To me, code has to open the form every day from a button on the sheet, search for the date and time on Sheet1 when the form opens and compare it to Now(). 

I turn my laptop off every night and turn it back on in the morning. Correct code would have to account for this. Is there a simple way to do all this without a huge code block?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,214,863
Messages
6,121,978
Members
449,058
Latest member
oculus

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