ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   date function (https://www.excelbanter.com/excel-worksheet-functions/115205-date-function.html)

Stan Halls

date function
 
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 ??

Gary L Brown

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 ??


Stan Halls

date function
 
Thank you for that i worked a treat,,,,,,

"Gary L Brown" wrote:

'/==========================================/
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 ??



All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com