Thread: date function
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary L Brown Gary L Brown is offline
external usenet poster
 
Posts: 219
Default date function

'/==========================================/
Sub TimeLeft()
'days,hours,min and secounds left till a given date
Dim dblTimeLeft As Double
Dim dblDays As Double
Dim dblHours As Double
Dim dblMinutes As Double
Dim dblSeconds As Double
Dim strDate As String

strDate = "10/31/2006 08:00 AM"

dblTimeLeft = DateValue(strDate) + TimeValue(strDate) - Now()
dblDays = Int(dblTimeLeft)
dblHours = Int((dblTimeLeft - dblDays) * 24)
dblMinutes = _
Int((dblTimeLeft - dblDays - (dblHours / 24)) * 24 * 60)
dblSeconds = _
Int((dblTimeLeft - dblDays - (dblHours / 24) - _
(dblMinutes / 24 / 60)) * 24 * 60 * 60)

MsgBox _
"Days: " & dblDays & vbCr & _
"Hours: " & dblHours & vbCr & _
"Minutes: " & dblMinutes & vbCr & _
"Seconds: " & dblSeconds & vbCr, vbInformation, _
"Time Left until " & strDate & "..."

End Sub
'/==========================================/
HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Stan Halls" wrote:

i am trying to creat a script than i can assign to a button, so when i click
on it a dialog box appears with which will show tha days,hours,min and
secounds left till a given date that i can adjust in the script ,,,,
I have mannaged to get one to work in lotus 123 but not sure how to do it in
excel, any ideas ??