Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rob_T
 
Posts: n/a
Default Time with decimal places?


Hi everyone,

I've written a little macro which is a countdown timer. I'm trying to
get it to countdown on screen showing decimal places in the seconds, to
do this I've set the format as "hh:mm:ss.00". I know this works for
general times as I've tried putting "=now()" and holding down F9.
However, when I run my macro it only counts down in whole seconds and
the decimal places just stay as "00".

This is my code:

Sub Countdown()

Dim StartTime As Double, CDL As Double, EndTime As Double, NowTime
As Double
Dim YesNo As Integer

CDL = Range("Timer")
StartTime = Now
EndTime = StartTime + CDL

Do
NowTime = EndTime - Now
If NowTime < 0 Then NowTime = 0
Range("Timer") = NowTime
Loop Until NowTime = 0

YesNo = MsgBox("Reset timer?", vbYesNo)

If YesNo = 6 Then Range("Timer") = CDL

End Sub

(apart from the fact that it has the proper indenting which this forum
seems to remove ;) )

I've tried dim-ing them as dates but that doesn't make any difference.
Any suggestions anyone?

Many thanks,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388

  #2   Report Post  
Posted to microsoft.public.excel.misc
Toppers
 
Posts: n/a
Default Time with decimal places?

Try:

Range("Timer") = Format(NowTime, "hh:mm:ss:00")

HTH

"Rob_T" wrote:


Hi everyone,

I've written a little macro which is a countdown timer. I'm trying to
get it to countdown on screen showing decimal places in the seconds, to
do this I've set the format as "hh:mm:ss.00". I know this works for
general times as I've tried putting "=now()" and holding down F9.
However, when I run my macro it only counts down in whole seconds and
the decimal places just stay as "00".

This is my code:

Sub Countdown()

Dim StartTime As Double, CDL As Double, EndTime As Double, NowTime
As Double
Dim YesNo As Integer

CDL = Range("Timer")
StartTime = Now
EndTime = StartTime + CDL

Do
NowTime = EndTime - Now
If NowTime < 0 Then NowTime = 0
Range("Timer") = NowTime
Loop Until NowTime = 0

YesNo = MsgBox("Reset timer?", vbYesNo)

If YesNo = 6 Then Range("Timer") = CDL

End Sub

(apart from the fact that it has the proper indenting which this forum
seems to remove ;) )

I've tried dim-ing them as dates but that doesn't make any difference.
Any suggestions anyone?

Many thanks,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388


  #3   Report Post  
Posted to microsoft.public.excel.misc
Rob_T
 
Posts: n/a
Default Time with decimal places?


No, that doesn't make any difference. But thanks for the suggestion.

Anyone else?

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388

  #4   Report Post  
Posted to microsoft.public.excel.misc
Toppers
 
Posts: n/a
Default Time with decimal places?

Rob,
Misread your post but I don't believe you can get milliseconds
without some VBA programming. I believe I MIGHT be able to dig something out
on my home m/c but don't hold your breath!

"Rob_T" wrote:


Hi everyone,

I've written a little macro which is a countdown timer. I'm trying to
get it to countdown on screen showing decimal places in the seconds, to
do this I've set the format as "hh:mm:ss.00". I know this works for
general times as I've tried putting "=now()" and holding down F9.
However, when I run my macro it only counts down in whole seconds and
the decimal places just stay as "00".

This is my code:

Sub Countdown()

Dim StartTime As Double, CDL As Double, EndTime As Double, NowTime
As Double
Dim YesNo As Integer

CDL = Range("Timer")
StartTime = Now
EndTime = StartTime + CDL

Do
NowTime = EndTime - Now
If NowTime < 0 Then NowTime = 0
Range("Timer") = NowTime
Loop Until NowTime = 0

YesNo = MsgBox("Reset timer?", vbYesNo)

If YesNo = 6 Then Range("Timer") = CDL

End Sub

(apart from the fact that it has the proper indenting which this forum
seems to remove ;) )

I've tried dim-ing them as dates but that doesn't make any difference.
Any suggestions anyone?

Many thanks,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388


  #5   Report Post  
Posted to microsoft.public.excel.misc
Rob_T
 
Posts: n/a
Default Time with decimal places?


Well, it seems to work just on the spreadsheet. As a test, on the same
spreadsheet I put another cell below the "Timer" range with exactly the
same format. In there I've put "=now()" and that counts in milliseconds
while the cell above (the countdown) counts only in seconds


It's not vital really, I just think it looks a bit cooler if you can
see the milliseconds rattling off

Cheers,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388



  #6   Report Post  
Posted to microsoft.public.excel.misc
Rob_T
 
Posts: n/a
Default Time with decimal places?


Well, it seems to work just on the spreadsheet. As a test, on the same
spreadsheet I put another cell below the "Timer" range with exactly the
same format. In there I've put "=now()" and that counts in milliseconds
while the cell above (the countdown) counts only in seconds


It's not vital really, I just think it looks a bit cooler if you can
see the milliseconds rattling off

Cheers,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388

  #7   Report Post  
Posted to microsoft.public.excel.misc
Toppers
 
Posts: n/a
Default Time with decimal places?

Rob,
Take a look he

http://www.tushar-mehta.com/excel/software/vba_timer/

HTH

"Rob_T" wrote:


Hi everyone,

I've written a little macro which is a countdown timer. I'm trying to
get it to countdown on screen showing decimal places in the seconds, to
do this I've set the format as "hh:mm:ss.00". I know this works for
general times as I've tried putting "=now()" and holding down F9.
However, when I run my macro it only counts down in whole seconds and
the decimal places just stay as "00".

This is my code:

Sub Countdown()

Dim StartTime As Double, CDL As Double, EndTime As Double, NowTime
As Double
Dim YesNo As Integer

CDL = Range("Timer")
StartTime = Now
EndTime = StartTime + CDL

Do
NowTime = EndTime - Now
If NowTime < 0 Then NowTime = 0
Range("Timer") = NowTime
Loop Until NowTime = 0

YesNo = MsgBox("Reset timer?", vbYesNo)

If YesNo = 6 Then Range("Timer") = CDL

End Sub

(apart from the fact that it has the proper indenting which this forum
seems to remove ;) )

I've tried dim-ing them as dates but that doesn't make any difference.
Any suggestions anyone?

Many thanks,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388


  #8   Report Post  
Posted to microsoft.public.excel.misc
Rob_T
 
Posts: n/a
Default Time with decimal places?


I'll see if I can give that a try. I'm not sure the IT people here will
like me installing unofficial stuff on my PC though. I'll see if I can
sweet-talk them ;)

Cheers,

Rob


--
Rob_T
------------------------------------------------------------------------
Rob_T's Profile: http://www.excelforum.com/member.php...fo&userid=4952
View this thread: http://www.excelforum.com/showthread...hreadid=556388

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting decimal time to standard time? mpendleton Excel Discussion (Misc queries) 4 May 12th 06 10:07 PM
Can you set to default the # of decimal places in Format Cells? Amy Setting up and Configuration of Excel 4 March 29th 06 05:08 PM
Highest & lowest place value / decimal places of cell value Neil Goldwasser Excel Worksheet Functions 2 March 15th 06 02:27 PM
Max decimal places SusieQ Excel Discussion (Misc queries) 1 July 13th 05 07:57 PM
DECIMAL PLACES IN FORMULAS excllent 1 Excel Worksheet Functions 5 June 1st 05 06:43 PM


All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"