Creating Continuous, Growing List

mcgonma

Board Regular
Joined
Nov 2, 2011
Messages
162
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
In column A I have a total number of items (e.g., A1=46.8, A2=43.4, A3=26.2, etc.).
In column B I have the total cost of all the items (e.g., B1=$4,201,063, B2=$1,841,198, B3=$1,069,026, etc.)
In column C I have the average cost of each item (i.e., C=B/A) (e.g., C1=$89,817, C2=42,457, C3=$40,802, etc.)

How can I set up column D so that I have the results of C1 replicated down by the same number of times indicated in A1, followed by the results of C2 replicated down by the number of times indicated in A2, followed by the results of C3 replicated down by the number of times indicated in A3, etc., etc. etc.?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
If the number in column A is not an integer, how do you decide how many times the C value should be replicated? For now, I just assumed all integers:

Book1
ABCD
1
24420106310502661050266
351841198368239.61050266
4210690265345131050266
51050266
6368239.6
7368239.6
8368239.6
9368239.6
10368239.6
11534513
12534513
13
Sheet2
Cell Formulas
RangeFormula
D2:D12D2=INDEX(C2:C10,MATCH(SEQUENCE(SUM(A:A),,0),SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A))))))
C2:C4C2=B2/A2
Dynamic array formulas.


This assumes your version of Excel has the SEQUENCE function. If not, please update your profile to show the version of Excel you're using. Also, the empty row on top is necessary.
 
Upvote 1
Solution
If the number in column A is not an integer, how do you decide how many times the C value should be replicated? For now, I just assumed all integers:

Book1
ABCD
1
24420106310502661050266
351841198368239.61050266
4210690265345131050266
51050266
6368239.6
7368239.6
8368239.6
9368239.6
10368239.6
11534513
12534513
13
Sheet2
Cell Formulas
RangeFormula
D2:D12D2=INDEX(C2:C10,MATCH(SEQUENCE(SUM(A:A),,0),SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A))))))
C2:C4C2=B2/A2
Dynamic array formulas.


This assumes your version of Excel has the SEQUENCE function. If not, please update your profile to show the version of Excel you're using. Also, the empty row on top is necessary.
This is great but how could it be made to instead list a number 1 - 100 depending on how many times it copies so in the above it would go 1 - 4 then 1 - 5 then 1 - 2
 
Upvote 0
Maybe:

Book1
ABCDEFGH
1
24420106310502661050266111050266
351841198368239.61050266221050266
4210690265345131050266331050266
51050266441050266
6368239.611368239.6
7368239.622368239.6
8368239.633368239.6
9368239.644368239.6
10368239.655368239.6
1153451311534513
1253451322534513
13
Sheet2
Cell Formulas
RangeFormula
D2:D12D2=INDEX(C2:C10,MATCH(SEQUENCE(SUM(A:A),,0),SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A))))))
E2:E12E2=LET(s,SEQUENCE(SUM(A:A)),t,SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A)))),s-INDEX(t,MATCH(SEQUENCE(SUM(A:A),,0),t)))
G2:H12G2=LET(s,SEQUENCE(SUM(A:A)),t,SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A)))),m,MATCH(s-1,t),CHOOSE({1,2},s-INDEX(t,m),INDEX(C2:C10,m)))
C2:C4C2=B2/A2
Dynamic array formulas.


If you have LET, then the G2 formula combines both the D and E formulas. If you don't have LET, the E2 formula would be:

Excel Formula:
=SEQUENCE(SUM(A:A))-INDEX(SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A)))),MATCH(SEQUENCE(SUM(A:A),,0),SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A))))))
 
Upvote 0
If the number in column A is not an integer, how do you decide how many times the C value should be replicated? For now, I just assumed all integers:

Book1
ABCD
1
24420106310502661050266
351841198368239.61050266
4210690265345131050266
51050266
6368239.6
7368239.6
8368239.6
9368239.6
10368239.6
11534513
12534513
13
Sheet2
Cell Formulas
RangeFormula
D2:D12D2=INDEX(C2:C10,MATCH(SEQUENCE(SUM(A:A),,0),SUBTOTAL(9,OFFSET(A1,0,0,SEQUENCE(COUNT(A:A))))))
C2:C4C2=B2/A2
Dynamic array formulas.


This assumes your version of Excel has the SEQUENCE function. If not, please update your profile to show the version of Excel you're using. Also, the empty row on top is necessary.
Erik...this solution is GORGEOUS!!!!! It works beautifully and is exactly what I was looking to accomplish!!!!
 
Upvote 0
Here is another way using Power Query.

PQ
ABCDE
1TimesCostIDAvg
244,201,06311,050,266
351,841,19821,050,266
421,069,02631,050,266
541,050,266
61368,240
72368,240
83368,240
94368,240
105368,240
111534,513
122534,513
Sheet1


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ID = Table.AddColumn(Source, "ID", each {1..[Times]}),
    Avg = Table.AddColumn(ID, "Avg", each [Cost]/[Times]),
    Expand = Table.ExpandListColumn(Avg, "ID"),
    ROC = Table.SelectColumns(Expand,{"ID", "Avg"})
in
    ROC
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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