Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you Subtract dates in VBA
I am trying to get VBA to sutract a date inputed from a text box from todays date and then divide all by 365.25 to find age. I would like this to be the value of the variable, varAge. Once varAge is known I would VBA to input the rest of the information from the other textboxes into the sheet corresponding to the correct age. I can do this in the Excel formula bar but I cannot make it work in VBA. Can anyone help? Thank you. Preston -- postlp60 ------------------------------------------------------------------------ postlp60's Profile: http://www.excelforum.com/member.php...o&userid=25532 View this thread: http://www.excelforum.com/showthread...hreadid=397376 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you Subtract dates in VBA
copy and paste this in your module (form or other module, except class)\
Sub MyProcedure() Dim MyAge If CDbl(Format(txtBirthDate, "mmdd")) = CDbl(Format(Date, "mmdd")) Then MyAge = DateDiff("yyyy", txtBirthDate, Date) Else MyAge = DateDiff("yyyy", txtBirthDate, Date) - 1 MsgBox "You are " & MyAge & " years old as of today" End Sub Ronin "postlp60" wrote: I am trying to get VBA to sutract a date inputed from a text box from todays date and then divide all by 365.25 to find age. I would like this to be the value of the variable, varAge. Once varAge is known I would VBA to input the rest of the information from the other textboxes into the sheet corresponding to the correct age. I can do this in the Excel formula bar but I cannot make it work in VBA. Can anyone help? Thank you. Preston -- postlp60 ------------------------------------------------------------------------ postlp60's Profile: http://www.excelforum.com/member.php...o&userid=25532 View this thread: http://www.excelforum.com/showthread...hreadid=397376 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Subtract if dates in the range between 2 dates. | Excel Worksheet Functions | |||
How to subtract 2 dates to get number of days.....please | Excel Worksheet Functions | |||
Subtract two dates | Excel Discussion (Misc queries) | |||
Subtract time and dates with restrictions | Excel Worksheet Functions | |||
subtract dates | Excel Programming |