Countdown in Userform

orangehairedboy

Board Regular
Joined
Feb 23, 2003
Messages
159
I would like to have a countdown in a userform that counts down 30 minutes, calls a function, and restarts the countdown at 30 minutes.

I can't figure out how to get the label I'm using for the time display to update to show a countdown.

Can anyone help me on this one?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you want something full on check out Ivan's site. Otherwise you could do something like this where TextBox1 is the number of seconds to coundown and it loops every second so the label is updated but when this runs you cant actually do anything in Excel so I wouldnt recommend this for 30 mins.

Code:
Private Sub cmdStart_Click()
Dim i As Integer
Select Case TextBox1.Value
Case ""
MsgBox "No value entered!"
Exit Sub
Case Else
For i = TextBox1.Value To 0 Step -1
Label2.Caption = i
Application.Wait (Now + TimeValue("0:00:01"))
'UserForm1.Repaint

Next i
End Select

MsgBox "Blast off!!"
End Sub
 
Upvote 0
Re: Countdown in Userform : Some thoughts

If you use a textbox for the time display, you won't need to repaint the form. (Only lock the textbox to prevent the user typing into it).

If you use a non-modal form, the user can continue working while the form is on. (But the timer will not operate while a cell is actually being edited).
 
Upvote 0
If you use an API timer, the timer will continue to go even while Excel is in edit mode.

Tom
 
Upvote 0

Forum statistics

Threads
1,215,972
Messages
6,128,027
Members
449,414
Latest member
sameri

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