Show countdown on userform on form opening- no control buttons.

Wilfred_E

New Member
Joined
May 9, 2019
Messages
44
Please, may I get a VBA to display countdown on a userform i.e. countdown to zero and do nothing but show MsgBox saying Time-Over? It will start counting moment the form opens, and so, no need for start/cancel buttons. Thank you.
 

Excel Facts

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

Maybe this?

VBA Code:
Sub Timer()
    Application.OnTime Now + TimeValue("00:00:01"), "StartCountDown"
End Sub
Sub StartCountDown()
    Dim DownFrom As Single
    DownFrom = 11
    Call Timer
    Range("A1").Value = Range("A1").Value + 1
    UserForm1.Label1.Caption = DownFrom - Range("A1").Value
    On Error Resume Next
    UserForm1.Show
    If Range("A1").Value = DownFrom Then
        Application.OnTime Now + TimeValue("00:00:01"), "StartCountDown", schedule:=False
        Range("A1") = ""
        MsgBox "Time-Over"
        Unload UserForm1
    End If
End Sub
 
Upvote 0
Hi Wilfred,

Maybe this?

VBA Code:
Sub Timer()
    Application.OnTime Now + TimeValue("00:00:01"), "StartCountDown"
End Sub
Sub StartCountDown()
    Dim DownFrom As Single
    DownFrom = 11
    Call Timer
    Range("A1").Value = Range("A1").Value + 1
    UserForm1.Label1.Caption = DownFrom - Range("A1").Value
    On Error Resume Next
    UserForm1.Show
    If Range("A1").Value = DownFrom Then
        Application.OnTime Now + TimeValue("00:00:01"), "StartCountDown", schedule:=False
        Range("A1") = ""
        MsgBox "Time-Over"
        Unload UserForm1
    End If
End Sub
Hi Sahak. Don't know what am doing wrong. I tested the code on an empty userform but the form didn't show the count down on the form on test running.
 
Upvote 0
You should have UserForm1 & Label1 on it & run macro "StartCountDown"
 
Upvote 0
You should have UserForm1 & Label1 on it & run macro "StartCountDown"
Yeah, I have done these earlier. Because I was testing with a new worksheet, I forgot I have not turn on the macro-setting. I later did and it works fine. Thank you very much, Sahak.
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,720
Members
449,050
Latest member
MiguekHeka

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