Compicated Formulas in MsgBox

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
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi rocksolid77,

Welcome to the forum!!

Could you please repost the formula in question as it hasn't posted properly (entirely) I'm afraid.

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top