How to evenly spread 97 input values across 100 output values

rpg1966

New Member
Joined
Mar 12, 2015
Messages
19
I have 97 input values that I need to spread over 100 output values, such that the total remains the same. In other words, each output value will be a 97/100th chunk of the relevant input values.

The image below shows a simplified example with 3 input values and 4 output values, i.e. each output value is a 3/4 chunk of one or two of the input values:

- the 1st output value is just 3/4 of the first input value
- the 2nd output value is the remaining 1/4 of the first input value, plus 1/2 of the next (second) input value
- the 3rd output value is the remaining 1/2 of the second input value, plus 1/4 of the next (third) input value
- the 4th output value is the remaining 3/4 of the third input value, plus ... nothing, as we have now completed the table

I'm not sure if this should be trivially simple? :unsure: But I can't think of a way to automate it; does anyone have any bright ideas?

1666184412570.png
 
I seem that we are trying to solve an unknown problem, and we know only how the OP thought "it" could be solved.

Could the objective of the work be described, forgetting how it could be done?

I'm not sure I understand your point. I have described the objective, i.e. splitting 97 input cells over 100 output cells.

I could do it manually, as described laboriously a few posts above, but next time it might be 96 input cells and 100 output cells. If there was an algorithmic way to do it, it would save a lot of time over manually typing in the splits into each output cell.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
@rpg1966 here is an XL2BB example I whipped up that has a few examples that seem to work. It also includes a partial portion of the 97/100.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCW
1Input Value 1Input Value 2Input Value 3Sum# of Input values# of Output values
212101436340.750.25
3Output Value 1Output Value 2Output Value 3Output Value 4
4988.510.536
5
6Input Value 1Input Value 2Input Value 3Input Value 4
71210141652450.80.2
8Output Value 1Output Value 2Output Value 3Output Value 4Output Value 5
99.68.49.611.612.852
10
11Input Value 1Input Value 2Input Value 3Input Value 4Input Value 5
12121014161870560.8333333330.166666667
13Output Value 1Output Value 2Output Value 3Output Value 4Output Value 5Output Value 6
14108.66666666710.3333333312.3333333313.666666671570
15
16
17
18
19# of Input values# of Output values
20971000.970.03
21Input Value 1Input Value 2Input Value 3Input Value 4Input Value 5Input Value 6Input Value 7Input Value 8Input Value 9Input Value 10Input Value 11Input Value 12Input Value 13Input Value 14Input Value 15Input Value 16Input Value 17Input Value 18Input Value 19Input Value 20Input Value 21Input Value 22Input Value 23Input Value 24Input Value 25Input Value 26Input Value 27Input Value 28Input Value 29Input Value 30Input Value 31Input Value 32Input Value 33Input Value 34Input Value 35Input Value 36Input Value 37Input Value 38Input Value 39Input Value 40Input Value 41Input Value 42Input Value 43Input Value 44Input Value 45Input Value 46Input Value 47Input Value 48Input Value 49Input Value 50Input Value 51Input Value 52Input Value 53Input Value 54Input Value 55Input Value 56Input Value 57Input Value 58Input Value 59Input Value 60Input Value 61Input Value 62Input Value 63Input Value 64Input Value 65Input Value 66Input Value 67Input Value 68Input Value 69Input Value 70Input Value 71Input Value 72Input Value 73Input Value 74Input Value 75Input Value 76Input Value 77Input Value 78Input Value 79Input Value 80Input Value 81Input Value 82Input Value 83Input Value 84Input Value 85Input Value 86Input Value 87Input Value 88Input Value 89Input Value 90Input Value 91Input Value 92Input Value 93Input Value 94Input Value 95Input Value 96Input Value 97
222468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100102104106108110112114116118120122124126128130132134136138140142144146148150152154156158160162164166168170172174176178180182184186188190192194
23Output Value 1Output Value 2Output Value 3Output Value 4Output Value 5Output Value 6Output Value 7Output Value 8Output Value 9Output Value 10Output Value 11Output Value 12Output Value 13Output Value 14Output Value 15Output Value 16Output Value 17Output Value 18Output Value 19Output Value 20Output Value 21Output Value 22Output Value 23Output Value 24Output Value 25Output Value 26Output Value 27Output Value 28Output Value 29Output Value 30Output Value 31Output Value 32Output Value 33Output Value 34Output Value 35Output Value 36Output Value 37Output Value 38Output Value 39Output Value 40Output Value 41Output Value 42Output Value 43Output Value 44Output Value 45Output Value 46Output Value 47Output Value 48Output Value 49Output Value 50Output Value 51Output Value 52Output Value 53Output Value 54Output Value 55Output Value 56Output Value 57Output Value 58Output Value 59Output Value 60Output Value 61Output Value 62Output Value 63Output Value 64Output Value 65Output Value 66Output Value 67Output Value 68Output Value 69Output Value 70Output Value 71Output Value 72Output Value 73Output Value 74Output Value 75Output Value 76Output Value 77Output Value 78Output Value 79Output Value 80Output Value 81Output Value 82Output Value 83Output Value 84Output Value 85Output Value 86Output Value 87Output Value 88Output Value 89Output Value 90Output Value 91Output Value 92Output Value 93Output Value 94Output Value 95Output Value 96Output Value 97Output Value 98Output Value 99Output Value 100
241.943.825.77.589.4611.3413.2215.116.9818.8620.7422.6224.526.3828.2630.1432.0233.935.7837.6639.5441.4243.345.1847.0648.9450.8252.754.5856.4658.3460.2262.1
25
Sheet1
Cell Formulas
RangeFormula
G2G2=SUM($A2:$C2)
J2,J12J2=LOOKUP(2, 1 / (A2:F2 <> ""), COLUMN(A2:F2))
L2,C20,L12L2= J2 / K2
M2,D20,M12,M7M2= 1 - J2 / K2
A4,A14,A9A4=A2 * L2
B4:C4B4=A2 * $M2 * (COUNT($A2:B2) - 1) + B2 * ($L2 - (COUNT($A$2:B2) - 1) * $M2)
D4D4=C2 * L2
G4G4=SUM(A4:D4)
G7G7=SUM($A7:$D7)
J7J7=LOOKUP(2, 1 / (A7:F7<>""), COLUMN(A7:F7))
L7L7= J7 / K7
B9:D9B9=A7 * $M7 * (COUNT($A7:B7) - 1) + B7 * ($L7 - (COUNT($A$7:B7) - 1) * $M7)
E9E9=D7 * L7
G9G9=SUM(A9:E9)
G12G12=SUM($A12:$E12)
B14:E14B14=A12 * $M12 * (COUNT($A12:B12) - 1) + B12 * ($L12 - (COUNT($A$12:B12) - 1) * $M12)
F14F14= E12 * L12
G14G14=SUM(A14:F14)
A20A20=LOOKUP(2, 1 / (A22:FF22 <> ""), COLUMN(A22:FF22))
B20B20=LOOKUP(2, 1 / (A23:FF23 <> ""), COLUMN(A23:FF23))
A24A24=A22 * C20
B24:AG24B24=A22 * $D20 * (COUNT($A22:B22) - 1) + B22 * ($C20 - (COUNT($A$22:B22) - 1) * $D20)


The 97/100 part is filled in up to the 33rd output value of the sample data used. Perhaps you can fill in the next few output values so we can figure out what you are trying to accomplish.

I used the formula that @kevin9999 supplied, cleaned up a bit, because it was much simpler than what I came up with.
 
Upvote 0
Solution
Thank you johnny.

That doesn't quite do what I'm looking for, as described in posts #1, #3, and especially #14. Post #14 shows how the nature of only taking a 97/100th chunk of each input cell means that eventually (in this case, at the 34th and 35th outputs) the output gets calculated from not the input cell with the same number and the one before, but the previous input cell and the one before that. For example, you can see that (say) the 20th output is calculated from the 19th and 20th input cells, but the 35th output is calculated from the 33rd and 34th input cells. The same shift will happen again at the ~66th/67th and ~98th/99th/100th cells, which is how the 100th output can take it's value from the 97th input (97/100ths of the 97th input, to be precise). However, the formulae you've provided for B24:AG24 only ever references the same input cell and the previous input cell. i.e. it doesn't handle the shift at the ~34th/35th outputs, and it can't handle the extra shift at the 66/67 and 98/99/100th outputs.

You (and Anthony47) ask if I can help you "figure out what you are trying to accomplish" / "describe the objective", but I can't see how I can explain it any better. Post #1 describes it in words, post #3 gives a diagrammatic explanation, and post #14 actually works through the first 35 outputs one-by-one; in particular, showing the shift that kevin999 can't seem to wrap his head around. It seems that I am not able to explain myself very well, sadly! Therefore, let's call this question solved, as I don't want to waste people's time with my inadequate explanation.
 
Upvote 0
I shall read again the messages you pinpoint, maybe (maybe) I'll get a better idea of the question (probably Johnny is much ahead of me)

However I still think that taking "the first 97/100th of the first cell", then taking "the remaining 3/100th from the 1st cell, and therefore 94/100th of the 2nd input cell" is HOW you are trying to solve the puzzle; should it be possible to describe the rules that govern this redistribution maybe (maybe) we could think of a different approach

By the way: which Office version do you use?
 
Upvote 0
I shall read again the messages you pinpoint, maybe (maybe) I'll get a better idea of the question (probably Johnny is much ahead of me)

However I still think that taking "the first 97/100th of the first cell", then taking "the remaining 3/100th from the 1st cell, and therefore 94/100th of the 2nd input cell" is HOW you are trying to solve the puzzle; should it be possible to describe the rules that govern this redistribution maybe (maybe) we could think of a different approach

By the way: which Office version do you use?

I have an Office 365 subscription; not sure what that means in terms of version numbers.
Edit: it says Version 2209 (Build 15629.20208)

I could explain why I am seeking this split of 97 inputs into 100 outputs (or maybe 96>100, or whatever combination in future), but it wouldn't change the requirement to split the cells as described. So I left the explanation out, as it's not relevant.

Thanks for checking in, but I think I'll just type in the calculations manually as per post #14, and hope that I don't often need to do this for other combinations of #inputs and #outputs!
 
Upvote 0
Ok the version.
Is this puzzle based on a 97 value to be splitted over 100 output cells, or generally on N values to M cells?

In the second case, how 3 values should be splitted over 5 output cells?
 
Upvote 0
I have 97 input values that I need to spread over 100 output values, such that the total remains the same. In other words, each output value will be a 97/100th chunk of the relevant input values.

If you just want to turn 97 input values into 100 output values, how about using the following:

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCT
1Percentage of each# of Output values thatEach Output value that
2# of Input Values# of Output ValuesInput value to keepneed to be addedneeds to be added
3971000.97395.06
4
5Input Values
62468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100102104106108110112114116118120122124126128130132134136138140142144146148150152154156158160162164166168170172174176178180182184186188190192194
7Output Values
81.943.885.827.769.711.6413.5815.5217.4619.421.3423.2825.2227.1629.131.0432.9834.9236.8638.840.7442.6844.6246.5648.550.4452.3854.3256.2658.260.1462.0864.0265.9667.969.8471.7873.7275.6677.679.5481.4883.4285.3687.389.2491.1893.1295.069798.94100.88102.82104.76106.7108.64110.58112.52114.46116.4118.34120.28122.22124.16126.1128.04129.98131.92133.86135.8137.74139.68141.62143.56145.5147.44149.38151.32153.26155.2157.14159.08161.02162.96164.9166.84168.78170.72172.66174.6176.54178.48180.42182.36184.3186.24188.18
9
10Sum of Input ValuesSum of Output Values
1195069506
12
Sheet2
Cell Formulas
RangeFormula
A3A3=MATCH(TRUE, ISBLANK(A6:FF6), 0) - 1
D3D3= A3 / B3
F3F3= B3 - A3
G3G3=(A11 - SUM($A8:OFFSET(A8,0,MATCH(TRUE, ISBLANK(A6:FF6), 0) - 1))) / ($B3 - $A3)
A8:CS8A8= $D3 * A6
A11A11=SUM(A6:OFFSET(A6,0,MATCH(TRUE, ISBLANK(A6:FF6), 0) - 1))
B11B11=SUM(A8:OFFSET(A8,0,MATCH(TRUE, ISBLANK(A8:FF8), 0) - 1)) + F3 * G3
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hello,

For a general approach (N values to M cells) an interpolation approach is to be preferred, I think.

For this approach you can use any interpolation function which can spill:
MrExcel_How to evenly spread 97 input values across 100 output values.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCX
1InputSum123
236121014
3Output1234
436988,510,5
5
6Input12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
795062468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100102104106108110112114116118120122124126128130132134136138140142144146148150152154156158160162164166168170172174176178180182184186188190192194
8Output123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
995061,943,821212125,702424247,583636369,4648484811,346060613,227272715,108484816,98969718,870909120,752121222,633333324,514545526,395757628,276969730,158181832,039393933,920606135,801818237,683030339,564242441,445454543,326666745,207878847,089090948,97030350,851515252,732727354,613939456,495151558,376363660,257575862,138787964,0265,901212167,782424269,663636471,544848573,426060675,307272777,188484879,06969780,950909182,832121284,713333386,594545588,475757690,356969792,238181894,119393996,000606197,881818299,7630303101,644242103,525455105,406667107,287879109,169091111,050303112,931515114,812727116,693939118,575152120,456364122,337576124,218788126,1127,981212129,862424131,743636133,624848135,506061137,387273139,268485141,149697143,030909144,912121146,793333148,674545150,555758152,43697154,318182156,199394158,080606159,961818161,84303163,724242165,605455167,486667169,367879171,249091173,130303175,011515176,892727178,773939180,655152182,536364184,417576186,298788188,18
Sheet1
Cell Formulas
RangeFormula
C1:E1C1=SEQUENCE(1,3,1,1)
B2B2=SUM(C2:E2)
C3:F3C3=SEQUENCE(1,4,1,1)
B4B4=SUM(C4:F4)
C4:F4C4=SUM(C2:E2)*sbInterp(C1:E1,C2:E2,SEQUENCE(1,4,C1,(E1-C1)/(4-1)))/SUM(sbInterp(C1:E1,C2:E2,SEQUENCE(1,4,C1,(E1-C1)/(4-1))))
C6:CU6C6=SEQUENCE(1,97,1,1)
B7B7=SUM(C7:CU7)
C8:CX8C8=SEQUENCE(1,100,1,1)
B9B9=SUM(C9:CX9)
C9:CX9C9=SUM(C7:CU7)*sbInterp(C6:CU6,C7:CU7,SEQUENCE(1,100,C6,(CU6-C6)/(100-1)))/SUM(sbInterp(C6:CU6,C7:CU7,SEQUENCE(1,100,C6,(CU6-C6)/(100-1))))
Dynamic array formulas.


A sample file (download and use at your own risk, but I use an up-to-date virus scanning program):

Regards,
Bernd
 
Last edited:
Upvote 0
Just for fun I went to this macro, that should split N values in a row to M cells according the OP algorithm; N cound be <, > or = to M
Code:
Sub SplitN2M()
Dim sStart As Range, dSPos As Range, oStart As Range
Dim sArr, qCnt() As Long, oArr()
Dim sSize As Long, tFrom As Long, dSize As Long, I As Long, J As Long
'
Set sStart = Range("B4")        '<<< Where the source range starts from
Set oStart = Range("B7")        '<<< The output starting position
Set dSPos = Range("B10")        '<<< The output size
'
sSize = Application.WorksheetFunction.CountA(sStart.Resize(1, 110))
dSize = dSPos.Value
sArr = sStart.Resize(1, sSize + 1).Value
ReDim qCnt(1 To UBound(sArr, 2))
ReDim oArr(1 To dSize + 3)
oStart.Resize(1, 115).ClearContents
'
tFrom = 1
For J = 1 To dSize
    For I = 1 To sSize
        If qCnt(tFrom) < dSize Then
            oArr(J) = oArr(J) + sArr(1, tFrom) / dSize
            qCnt(tFrom) = qCnt(tFrom) + 1
        Else
            tFrom = tFrom + 1
            oArr(J) = oArr(J) + sArr(1, tFrom) / dSize
            qCnt(tFrom) = qCnt(tFrom) + 1
            If qCnt(tFrom) > dSize Then Stop    'Never?
        End If
    Next I
Next J
oStart.Resize(1, UBound(oArr)).Value = oArr
'Range("H20").Resize(1, UBound(qCnt) + 1) = qCnt
Beep
End Sub
The lines marked <<< need to be customized according the comment

I used it on the attached BB2XL sheet:
BR1 Sales_Ledger RECON(9.2 (version 1).xlsm
ABCDEFGHIJKLMN
2
3
4Source Serie58751692769912
5
61234567891011  
7Dest Serie 266,818 266,818 71,909 23,182 198,000 314,545 328,545 349,545 362,545 414,545 414,545
8
9Source Vals5
10Dest Cells11
11
12
13
Foglio8
Cell Formulas
RangeFormula
C6:N6C6=IF(B6<>"",IF(B6+1<=$B$10,B6+1,""),"")
B9B9=COUNTA(B4:DZ4)


Then I used Worksheet_Change to start automatically the macro when the parametres changes (Source serie, Destination cells):
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$10" Or Target.Row = 4 Then
    Application.EnableEvents = False
    Call SplitN2M
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,230
Members
449,303
Latest member
grantrob

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