unique combinations generator

mikiel111

New Member
Joined
Mar 17, 2020
Messages
38
Office Version
  1. 365
Hi there,

I`ve got this issue which i just cannot seem to get to the bottom of.
I need a unique combination generator from entries in 1 column. To elaborate, I have 1 column with any number of rows (A, B, C, D etc...) in sheet A & I need to output unique combinations of all the entries from that column in groups of 5 in Sheet B
So let`s say I have Column 1 with A, B, C, D & E in the rows. I need to output the unique combinations of those (e.g. AAAAA AAAAB AAAAC, AAAAD, AAABC, AAABD etc...). The order of the letters is not important, so tby that I mean if I have AAAAB I dont want AAABA, AABAA, ABAAA & BAAAA.
I found an excel file on the internet which does what seems like I need it to do but the knowledge behind it is waaaaayy beyond me (hence why i`m reaching out for help) so I cannot copy it, see whats happening or recreate it in my own file.

Is there some way I can attach it so you see what I am talking about?
 
.....




Well done! That's good to hear.
What if in sheet daily meal macro I want to put stuff above the rows i`m using or I want to delete the A column. So for example my first entries would go in row 4 not 2 and would shift to from Column C to B, and E to D etc...
Same with the other sheet Meal List.
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
We have defined two worksheet scoped names: StartRow, pointing to:
='Meal List''!$A$10 (the start of my element list), and
='Daily Meal Macro'!$C$2 (the first output cell for the combinations).

This is how the code uses these names:

VBA Code:
'Input - get the elements starting from 'Meal List'!C10
With Worksheets("Meal List")
    Set rng = .Range("A" & .Range("StartRow").Row & ":A" & .Range("A" & Rows.Count).End(xlUp).Row)
End With

'...
        
'Output - write to alternate columns starting at 'Daily Meal Macro'!C2
With Worksheets("Daily Meal Macro").Range("StartRow")
    '....
End With

If, for example, you insert two rows at the top of 'Daily Meal Macro', StartRow will adjust automatically to 'Daily Meal Macro'!$C$4, and the code will put the output in the correct place.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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