Easy 5 second timer

berg891832

Well-known Member
Joined
May 2, 2002
Messages
509
Okay,

I just want an easy timer.

A user clicks a button, and after 10 seconds, a message box appears.

Basically, I am new at coding. I know just enough to be dangerous. I want to create a little timer when the user clicks the button, it starts, and they do data entry until the timer stops.

Berg
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi Berg,

Set up a button in the worksheet to run the following code (attached to the worksheet):

Private Sub Gonow_Click()
Dim NextTime As Date
NextTime = Now + TimeValue("00:00:10")
Application.OnTime NextTime, "Done_time"
End Sub

Set up a new module in the project with the following code:

Public Sub Done_time()
MsgBox ("Your time is up.")
End Sub

After you click on the button in the worksheet to run "Gonow", you can still enter data & edit cells until the 10 seconds runs out, when you will see the message box.

Cheers,
Linus
 
Upvote 0
the only way i could get this to work linus, was to take the Private out of your...
Code:
Private Sub Gonow_Click() 
Dim NextTime As Date 
NextTime = Now + TimeValue("00:00:10") 
Application.OnTime NextTime, "Done_time" 
End Sub
...routine.

other than that, works great!!
 
Upvote 0
Good to hear that it works for you.

Then, if you want to disable the worksheet for further input or something like that, put the code after the MsgBox in the Done_time module.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

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