+ Reply to Thread
Results 1 to 4 of 4

Distribute a total value evenly to an amount of cells considering certain conditions

  1. #1
    Registered User
    Join Date
    08-31-2017
    Location
    ecuador
    MS-Off Ver
    2010
    Posts
    2

    Exclamation Distribute a total value evenly to an amount of cells considering certain conditions

    Hi to all,

    I wonder if someone could help me with a VBA code (formula) or excel formula in order calculate a distribution:

    EJEMPLO.png

    As shown in the image, i want to make a distribution of a total value between A to F (B2: F2),

    The formula should consider:

    1) Distribute the amounts considering the demand as a priority.
    2) It should distribute in a way where every Segment A to F receives 1 unit in order till the total value stocks out.
    3) When a DEMAND is fullfilled it should pass to the next Segment.
    4) ONLY when all demands are fullfilled it should asign evenly 1 unit to all segments until it stocks out.

    Example:

    Total value = 6

    The distribution should start with

    E =1 then
    D= 1 then
    C= 1 then
    B= 1 then
    A= 1 till now 5 units are asgined then it should start with E again

    Final result:

    E =2
    D= 1
    C= 1
    B= 1
    A= 1

    Thank you!
    Attached Images Attached Images

  2. #2
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Distribute a total value evenly to an amount of cells considering certain conditions

    @jorgebeto16

    I have come up with the below code that I believe will serve your purposes:

    Please Login or Register  to view this content.
    This should accurately perform what you want. I have tested this in my own workbook and the results seem correct:
    Priority Allocation.PNG

    As a note this particular code would need to be ran after every change to your data set. Other sources would enable you to utilize automation based on cell changes, etc. Please let me know if this is not close enough to be adapted to your immediate needs.

    Thanks,

    DarkF1ame

    P.S. - If this does indeed resolve your issue please mark this thread as "Solved".
    Attached Images Attached Images

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Distribute a total value evenly to an amount of cells considering certain conditions

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    08-31-2017
    Location
    ecuador
    MS-Off Ver
    2010
    Posts
    2

    Re: Distribute a total value evenly to an amount of cells considering certain conditions

    @DarkF1ame

    It's pretty close, and it has helped me a lot to understand how it will possibly work, but i need it to follow the conditions, i think i can explain me better :

    DISTRIBUTION TABLE.png

    In the example :

    Total value 20:
    // The formula is supposed to assign 1 unit to every segment as long as it never surpass it's total value and the order will start from Max to min

    A B C D E
    1 1 1 1 1 TOTAL 5 //Remaining 15

    A B C D E
    2 2 2 2 2 TOTAL 10 //Remaining 10 ---> At this point SEGMENT "D" Has reached its total demand (2), so the formula/ code needs to exclude this segment and
    stop assigning more units for now.

    A B C D E
    3 3 3 2 3 TOTAL 15 //Remaining 5 ---> At this point SEGMENT "B & E" Has reached its total demand (3), so the formula/ code needs to exclude this segment
    and stop assigning more units for now.

    A B C D E
    5 3 7 2 3 TOTAL 20 //Remaining 0 ---> At this point NEITHER SEGMENT "A or C" Has reached its total demand BUT the total amount has stock out so it wont
    assign any more units.

    Consider also example
    TOTAL VALUE 30 (ROW 3):

    A B C D E
    12 4 5 3 6 TOTAL 30 // Remaining 0 -- > ALL SEGMENTS reach its demand and after that the code assigns 1 unit per segment following its DEMAND ORDER
    (MAX to min)

    How many units each segment receive in addition to its original demand?:

    A B C D E
    2 1 1 1 1 As you can notice only SEGMENT "A" received 2 additional units, thats because the code will assign 1 Unit to each SEGMENT starting with the one
    that has Highest DEMAND


    Thanks for your help, hope i have been clear with the examples

+ 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] Distribute Data Evenly Among n Cells
    By TimBZKK in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-17-2018, 02:02 AM
  2. Evenly distribute a number across several cells
    By gbursson in forum Excel General
    Replies: 2
    Last Post: 02-18-2015, 05:51 AM
  3. [SOLVED] Distribute Tasks Evenly
    By karthikcoep in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2015, 05:48 AM
  4. Distribute variables evenly
    By Jovanator in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-18-2014, 12:15 PM
  5. Distribute Values Evenly Across Cells
    By Crunchmeister in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-09-2014, 08:10 AM
  6. Evenly distribute numbers
    By captain118 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2013, 01:27 AM
  7. Replies: 1
    Last Post: 11-29-2010, 09:09 PM

Tags for this Thread

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