Compicated Formulas in a 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"<="" pre=""> Where A2 is the most recent date
and A1 is the oldest date
and will return the answer in the following format x Years, X Months, X Days

What I'm trying to do is have this as a macro with input boxes and a MsgBox rather than have the actual calculations being done in the worksheet. Unfortunately I'm still very noob with VBA and am not sure how to go about this, or if it's even possible.

I assume I can just have the value of the input boxes added to cells on the spreadsheet, calculate it in the sheet and return the value of the cell as a message box but was hoping there was some way to do this without affecting the contents of the sheet.

There is an 8 year old thread on this but i thought it would be better to start a new one. http://www.mrexcel.com/forum/showthread.php?t=83164

Also, if there's a way to do this with cell selections instead of input boxes that would be awesome.
Thanks in advance for any help!
</day(a1)),-1)))&"></month(a1),and(month(a2)=month(a1),>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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