+ Reply to Thread
Results 1 to 11 of 11

Distribute specific amount to months

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Distribute specific amount to months

    Hello everyone
    I have specific amount (200) and I need UDF function that enables me to distribute this amount according to the following
    For example:
    If start date is 25 / 3 / 2016 (March) & End date is 3 / 7 / 2016 ( July)

    So the number of days in March is 7 and the number of days in July is 3
    and other months [April - May - June] are full days

    Now I calculated the expected for the first month (March) with this formula
    Please Login or Register  to view this content.
    and for the last month (July) with this formula
    Please Login or Register  to view this content.
    As for the rest of full months : (200 - sum(the first month , the last month)) / the number of full months

    Can it be done using UDF function which refers to Start date & End Date & The amount (Cost)
    These are the three parameters

    Hope it is clear
    Thanks advanced for help
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Distribute specific amount to months

    if your dates inclusive? or exclusive of start and finish?

    also may has 31 days...your example shows 30
    Last edited by humdingaling; 05-23-2016 at 02:20 AM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Distribute specific amount to months

    see my attempt of UDF
    note i changed the headers to be actual dates in order to recognise months
    i added additional UDF endofmonth to mimic EOMONTH in VBA
    which i took from
    http://answers.microsoft.com/en-us/o...2-0594c350ade2
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Distribute specific amount to months

    Thank you very much for this great solution
    But it depends on the number of days I think and this caused incorrect results ( not as expected)
    Just we depend on the number of days for the start and end dates only
    but the rest of month in between would be distributed equally (as in example there are three months in between so the rest of the cost (200 - (14 + 6)) = 180 and 180 / 3 = 60

    Another point i don't need the fourth parameter .. the formula of UDF would be put in twelve cells (months of the year) so no need for this parameter (I hope it can be hard-coded instead)
    Hope this make any sense for you
    Best regards

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Distribute specific amount to months

    Please Login or Register  to view this content.
    i have replicated your outputs based on your information

    the fourth parameter is the anchor point
    it needs to know where in the 12 cells to start ....

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Distribute specific amount to months

    Thanks a lot for this wonderful solution
    You are great

    Just one point as for the fourth parameter .. Can you skip it and depend on the months numbers (1 for January, 2 for February ... as I am afraid of regional settings to affect the UDF ..) so I think numbers will not affect it
    Thank you very much

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Distribute specific amount to months

    it would require a little of rework but yes you could use 1,2,3,etc
    the issue is because it is a UDF people can put the wrong month in the wrong cell

    if it was a simple macro then you can of course just hard code the cell itself

    i am not sure how to extract the address for UDF based on where the formula is placed..... i am not sure if it is possible
    will do some research

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Distribute specific amount to months

    Thanks a lot for reply
    If it is possible to be done by macro not UDF , It is ok ..do it using subroutine not UDF

  9. #9
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Distribute specific amount to months

    I think the manual formulas are not correct.

    For example, let's say StartDate = 1 Jan, EndDate = 2 Jan, Cost = 200
    The average cost should be : 200 / (EndDate - StartDate + 1) = 100 --> (1 Jan) 100 + (2 Jan) 100 = 200 --> correct
    If you use : 200 / (EndDate - StartDate) = 200 --> (1 Jan) 200 + (2 Jan) 200 = 400 --> not correct

    So formula on F9 should be :
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and formula on J9 should be :
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    The UDF below is using (EndDate - StartDate + 1) syntax, but if you still want the original formula, then uncomment the three lines (and remove 3 lines above them).
    Please Login or Register  to view this content.
    Usage :
    Formula on D3 :
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and copy to right

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Distribute specific amount to months

    @Mr. Karedog
    Thank you very very much for this wonderful and fascinating solution and analysis ..Now I have the choice between both of them
    Best and kind regards

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Distribute specific amount to months

    You are welcome, glad to help.


    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How can I distribute a dollar amount into an odd number of rows?
    By cliff.clayman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-31-2016, 09:36 PM
  2. Distribute revenue across months
    By Carolinanilorac in forum Excel General
    Replies: 3
    Last Post: 10-26-2015, 01:28 AM
  3. Distribute revenue across months
    By Carolinanilorac in forum Tips and Tutorials
    Replies: 1
    Last Post: 10-25-2015, 08:55 PM
  4. Distribute no of account and amount equally to callers
    By Apple Ling in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2014, 06:34 AM
  5. Distribute standard reserve amount in Respectively ?????
    By Skashusen in forum Excel General
    Replies: 1
    Last Post: 09-15-2013, 03:28 PM
  6. Need a formula to distribute an amount to specified fields
    By beth.randall in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-21-2013, 09:40 AM
  7. [SOLVED] Using Lookup to distribute amount over a given duration
    By StarHunter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-16-2012, 06:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1