# List Combinations dynamically, using VB.

#### jmaruta

##### New Member
Hi guys,

I need your help. Tried to check other post, but they don't exactly apply to my case.

So...

I have a list of names (let's say: A,B,C,D,E,F,G,H,I and J) and each one of them as a number - integer, (e.g. A-34; B-100; C-5; etc...) in another collumn.

Now, i would like to have a code that would publish all possible combinations taking into account 2 things:

- the Order of each letter matter;
- the sum of the numbers in each combination, cannot be more than 33;
- I might need to add letters (K, L, M, ...) and related numbers, frequently.

And if the Order restriction didn't apply, how would it be?

Best regards.

Last edited:

### 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.

#### btomjack

##### Board Regular
Firstly, when order matters, it's called permutations. When order doesn't matter, it's called combinations. This can be VERY important depending on how many names we're dealing with; it could be the difference between thousands of calculations and billions.

If I understand what you're saying, you want to order the names (letters) in some way (alphabetically?), but you only want to include those names whose corresponding numbers sum to 33 or less. Is this correct? Also, how many names are you dealing with, and what is the format?

#### jmaruta

##### New Member

I'll be dealing with around 10 names (min:5; max:20).

Trying to explain in other words, i would like to get a function that for each set of names (letters) and their corresponding numbers would give me all ways there is to arrange the letters in groups, taking into account that the sum of each group cannot be more than 33.

Example:

Column A: A | B | C
Column B: 10 | 33 | 3

Result: B + A&C

thks

#### btomjack

##### Board Regular
I started working on this only to come to a pretty substantial stumbling block. Basically, I don't know a way to skip those combinations that have already been chosing. I could probably come up with a way to work around it, but I just don't have the time to do so.

I hate to do this, but it doesn't look like I will be able to help you further. Sorry.

#### jmaruta

##### New Member
Thanks a lot, anyway. Hope someone else can help.

regards

Replies
8
Views
206
Replies
6
Views
375
Replies
1
Views
144
Replies
4
Views
331
Replies
4
Views
120

1,195,667
Messages
6,011,049
Members
441,580
Latest member
BornholmerBjarne

### 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.

### Which adblocker are you using?

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

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