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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
887
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
 

Wilfred_E

New Member
Joined
May 9, 2019
Messages
44
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.
 

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
887
You should have UserForm1 & Label1 on it & run macro "StartCountDown"
 

Wilfred_E

New Member
Joined
May 9, 2019
Messages
44
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.
 

Forum statistics

Threads
1,144,390
Messages
5,724,074
Members
422,535
Latest member
navjeet

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