+ Reply to Thread
Results 1 to 4 of 4

Distribute amount in a variable range of columns

  1. #1
    Registered User
    Join Date
    10-10-2019
    Location
    Rotterdam
    MS-Off Ver
    2018
    Posts
    2

    Lightbulb Distribute amount in a variable range of columns

    Hi all,

    I am trying to distribute an amount across a set of adjacent columns, based on a 'capped' numbers. For instance, if the amount to distribute is 105 and the 'capped' number for that row is 50, then I'd like to results to be distributed as: 50, 50, 5 (remainder). Not split evenly, and across a varying number of columns.

    I got it working with the following formula: =MAX(0;IFERROR(MIN($C7;$C7+B7;$B7-SUM($C7:C7));0);0)

    However, the trick is that the amount should start to be distributed in a given column (which can change), based on the result of a PivotTable.

    The logic:
    1. G106 contains the number to be distributed (e.g. 305)
    2. H106 contains the 'capped' numbers (e.g. 50)
    3. Columns J106:V106 will receive the distribution of the number in (1)
    4. Start the calculation on a given week, based on a PivotTable.

    Attention: The PivotTable can indicate that week 2 contains 105 and week 3 contains 200 (amounting to 305, number in G106); therefore, the calculation must first distribute 105 as from week 2 and then start the distribution of the amount from week 3 (200), based on the capped amount of 50; The result would then be (week 1 to 8): 0, 50, 50, 50, 50, 50, 50, 5

    Maybe best is to create the VBA code and assign it to my own formula?

    Thank you!
    Last edited by johndoedoe; 10-11-2019 at 07:16 AM.

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Distribute amount in a variable range of columns

    Upload a sample. To upload Go Advanced - Manage Attachments -
    Click the * to say thanks.

  3. #3
    Registered User
    Join Date
    10-10-2019
    Location
    Rotterdam
    MS-Off Ver
    2018
    Posts
    2

    Re: Distribute amount in a variable range of columns

    Hi,

    Thank you for your answer. Attached is a sample example: the Pivot Table drives the quantity to be distributed in what week.

    Thank you for your time!
    Best regards,

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,540

    Re: Distribute amount in a variable range of columns

    Perhaps this will help.
    On Sheet 1 I attempted to construct a table of source data (columns A:C) based on the information in rows 11:16 of Sheet 2.
    Column D is then populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The pivot table on Sheet 1 then displays the data in the fashion shown at the top of Sheet 2.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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] Macro to select a variable row range and copy it down a variable amount of times
    By JPoFresh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2019, 10:40 AM
  2. [SOLVED] Macro to select a variable cell range and copy it down a variable amount of times
    By JPoFresh in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-18-2019, 09:17 PM
  3. macro to distribute the amount in date range
    By ncpavan08 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2016, 06:40 AM
  4. How to distribute on amount in to different cells depending on the dale range
    By saidmalikov in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2014, 11:51 AM
  5. Autofill to the right for variable amount of columns
    By sideshow1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2013, 05:31 PM
  6. [SOLVED] Transpose Variable Amount of Columns in Range
    By Ronjay24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2013, 04:25 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