rocksolid77
New Member
- Joined
- Sep 19, 2011
- Messages
- 18
Hi All, Any help will be greatly appreciated. Basically what I'm trying to do is to create a macro that can tell us how much time has passed between two dates. This can be accomplished with the following formula: =YEAR(A2)-YEAR(A1)-IF(OR(MONTH(A2)<MONTH(A1),AND(MONTH(A2)=MONTH(A1), DAY(A2)<DAY(A1))),1,0)&" years, "&MONTH(A2)-MONTH(A1)+IF(AND(MONTH(A2) <=MONTH(A1),DAY(A2)<DAY(A1)),11,IF(AND(MONTH(A2)<MONTH(A1),DAY(A2) >=DAY(A1)),12,IF(AND(MONTH(A2)>MONTH(A1),DAY(A2)<DAY(A1)),-1)))&" months, "&A2-DATE(YEAR(A2),MONTH(A2)-IF(DAY(A2)<DAY(A1),1,0),DAY(A1))&" days" Where A2 is the most recent date and A1 is the oldest date. And it will return the time between the dates as follows "X Years, X Months, X Days" What I wanted to do was set up a Macro so that rather than have this as a formula in a cell I could use two input boxes and return the value in a message box. Unfortunately I'm still very noob and am not sure how to go about coding this. I know I can have the input box add the values to the sheet, make the calculation on the sheet and then return the cell value with the answer as a MsgBox but was wondering if there was a way to go about this without affecting the contents of the worksheet. I found a thread related to this but it's almost 8 years old and I didn't want to bump it. http://www.mrexcel.com/forum/showthread.php?t=83164 Thanks in advance