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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

berg891832

Well-known Member
Joined
May 2, 2002
Messages
509
Well, I have to be able to do data entry on the workbook while the macro is running.

berg
 

Linus_99

Board Regular
Joined
Aug 28, 2002
Messages
145
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
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
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!!
 

Linus_99

Board Regular
Joined
Aug 28, 2002
Messages
145
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.
 

Forum statistics

Threads
1,171,144
Messages
5,874,034
Members
433,017
Latest member
inxcndd

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
Top