mardi 24 février 2015

Excel countdown code error when reaching 0

I currently have a code that acts as a countdown timer. The reason I'm not using a timer function or simply using the "CountUp" portion to countdown for me is because i'd like it to self adjust (another code could be running causing the calculation time for the other countdown methods to vary and be lengthy). Whenever the code reaches zero it causes an error: Application defined or object defined error.



Sub CountupONE()
Dim CountDownONE As Date

CountDownONE = Now + TimeValue("00:00:01")

Application.OnTime CountDownONE, "RealcountONE"
End Sub


Sub RealcountONE()
Dim countONE As Date
Dim counterONE As Date

counterONE = Now - Sheets("Sheet1").Range("$A$11").Value
countONE = Sheets("Sheet1").Range("$B$8").Value - counterONE
'MsgBox countONE
Sheets("Sheet1").Range("$C$8") = countONE
'Sheets("Sheet1").[C8] = TimeValue("12:00:00 AM")

If countONE = TimeValue("12:00:00 AM") Then

Beep
[C11].Value = Now
[C11].NumberFormat = "h:mm:ss AM/PM"
Application.Speech.Speak ("Platen one is done")
Call BeginGraphing

Exit Sub

End If

Call CountupONE
End Sub

Aucun commentaire:

Enregistrer un commentaire