Sort a list of combinations based on the numerical values from each cell

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
347
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello!
I have a range of cells with numerical combinations (A8:A38) equal with a given sum (A7), generated on the basis of a built-in list (A1:B5). Each combination contains in this case 3-5 values, but its length may depend on the size of range and the target number. I need a formula, macro etc., to sort all combinations in ascending series, according to the number of elements (1,2,3 etc.) from each cell, and if possible the content of that cell to be sorted from 1 to 9.

Thank you!
Book1.xlsm
AB
116
227
338
449
5510
6
720
81,6,2,7,4
91,6,2,3,8
101,6,3,10
111,6,8,5
121,6,4,9
131,2,7,10
141,2,3,4,10
151,2,3,9,5
161,2,8,4,5
171,2,8,9
181,7,3,4,5
191,7,3,9
201,7,8,4
211,4,5,10
221,9,10
236,2,7,5
246,2,3,4,5
256,2,3,9
266,2,8,4
276,7,3,4
286,4,10
296,9,5
302,7,3,8
312,3,5,10
322,8,10
332,4,9,5
347,3,10
357,8,5
367,4,9
373,8,4,5
383,8,9
Sheet1
Cell Formulas
RangeFormula
A8:A38A8=TRANSPOSE(FindSumCombinations(A1:B5,A7))
Dynamic array formulas.
 
Last edited:
I mean you have an extra column to aid in sorting ... you can sort a range of more than one column. Does that make sense?
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I mean you have an extra column to aid in sorting ... you can sort a range of more than one column. Does that make sense?
I posted the table with the combinations sorted in one column. If I understand correctly, you suggest me to use as many extra columns as series of combinations are, in order to sort them. It means also to make a lot of operations manually and to split the entire content in other sections. As I mentioned before, I'm interested in process the respective data within a single column, and find a solution as much as possible to automate this operation(s). Thank you!
 
Upvote 0
No, you do not understand correctly. I am suggesting that you have a column next to your output that calculates the number of elements per cell of output, because you said that you wanted that to be the major sorting factor. Then you refer to the output AND the new column in your formula that does the sorting.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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