Roggy_Swiss
New Member
- Joined
- May 30, 2013
- Messages
- 10
Hi all. I am trying to automate a Prepayment file. Basically I have the following data given in a row (entered via UserForm: -Amount of Invoice (+currency etc but not relevant in this context), start date, end date. In the columns there are months starting in July 2013 to June 2014. As I am setting a VBA controlled file with userforms, I need to automate the calculation of the amount in each specific month. So if an invoice is EUR 15000 for lets say Insurance for October, November, December 2013, I want the formula to look at start date, end date and the enter the values in each month concerned, in this case in the colums Oct, Nov and Dec 12 of EUR 5000 in each (Month approach). But as an invoice is not always for exact whole months, but sometimes starting on the 15th and ending on the 5th I would very much prefer a Day approach. Currently I have the following formula: =IFERROR(($M5/(DATEDIF($N5;$O5;"d"))*IF(ISERROR(DATEDIF(MAX($N5;P$4);MIN($O5;Q$4);"d"))=TRUE;"";DATEDIF(MAX($N5;P$4);MIN($O5;Q$4);"d")));"") ---- M5=Invoice amount, N5=Start Date, O5=End Date, P4=Jul 13,Q4=Aug 13 etc. This works quite good but the last month is alway a bit odd, meaning if the last month has 31 days the formula gives the same value as for a month with 30 days. Could anyone help me get the days right? I would be quite happy to have shorter formula than the one above. THANKS ALOT ALREADY!!! Regards, Roggy