- 31 Jul 2020 às 18:12
#57614
Pessoal estou usando o código abaixo para fazer um cronômetro regressivo (countdown), porém estou precisando de um códio para interromper ou parar essa macro.
Código: Selecionar todos
Dim gCount As Date
Sub Timer()
gCount = Now + TimeValue("00:00:01")
Application.OnTime gCount, "ResetTime"
End Sub
Sub ResetTime()
Dim xRng As Range
Application.StatusBar = False
Set xRng = Application.ActiveSheet.Range("E1")
If xRng.Value > 0 Then xRng.Value = xRng.Value - TimeSerial(0, 0, 1)
If xRng.Value > 0 Then
Application.StatusBar = VBA.Format(xRng.Value - TimeSerial(0, 0, 1), "hh:mm:ss")
Else
Application.StatusBar = "Contagem regressiva concluída."
End If
If xRng.Value <= 0 Then
MsgBox "Contagem regressiva concluída.", 0, "Final"
Application.Speech.Speak "Estudo concluído"
Exit Sub
End If
Call Timer
End Sub