# TIMER COUNTDOWN



## SQUIDD (Dec 29, 2022)

Hi All

I am trying to make a countdown timer. In a userform.The userform is called UI

The problem i am having, is this

if MY_TIME as in the past, the timer counts up, showing the elapsed time. This is correct.
HOWEVER
if MY_TIME is in the future, i get a huge number, like nearly 24 hours, counting up.

its like i cant get negative time.

Any help would be appriciated



```
Sub UPDATE_CLOCK()
Dim MY_TIME As Date
Dim DIFF As Date
UI.CLOCK = Format(Now, "HH:MM:SS")
If UI.CB1 <> "" Then
    MY_TIME = Left(UI.CB1, 5)
    DIFF = Format(MY_TIME - Now, "HH:MM:SS")
    UI.COUNT_DOWN = DIFF
End If
Application.OnTime Now + TimeSerial(0, 0, 1), "UPDATE_CLOCK"
End Sub
```


----------



## pjmorris (Dec 29, 2022)

change DIFF = Format(MY_TIME - Now, "HH:MM:SS") to DIFF = Format(MY_TIME - Time, "HH:MM:SS")

The reason you have a problem is because Now returns a date element.  Time only returns a time.  

Seems to work for me.

HTH


----------



## Micron (Dec 29, 2022)

SQUIDD said:


> the timer counts up, showing the elapsed time. This is correct.





SQUIDD said:


> I am trying to make a countdown timer


These goals are mutually exclusive? How can the same timer increment (count up) showing elapsed time and be correct and still count down (which is typically to zero)? If you're saying you want negative numbers you could try multiplying by -1.


----------



## SQUIDD (Dec 29, 2022)

Hi pjmorris, 

that worked perfectly thankyou.

Micron, thanks for your help too.

Dave


----------



## pjmorris (Jan 4, 2023)

Delighted to have helped. Thanks for the feedback.


----------

