3
2
Please note my question is different from the suggested duplicate. The suggested duplicate does not show all possible variations based on the number of options, so an input of 3 can have a variation of 1, 2, and 3 of the inputs. The suggested duplicate always provides 3 inputs per variation.
Furthermore, my question also asks for variations to show all possible orders of the inputs too. The suggested duplicate always shows column A at the left most position of the output, column b in the middle of the output and column c at the left of the output.
Therefore, the suggested duplicate does not answer my question.
Original Question
How do I go about creating a formula which takes any number of given input values, and then generates an output value with all possible combinations permutations based on the input values given.
For example, if the input values where as following
One
Two
The output generated should be something like this
One
OneTwo
Two
TwoOne
Here is what it should look like if 3 values are given:
Does anyone know how to do this in Excel?
I would like to be able to type in any number of input values and the input values will be any word, phrase, number, letters, or a combination permutation of all of those.
I have given this a try https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/146983-all-possible-combinations-from-single-column but it does not seem to work.
In column A, if I type (one word per row):
One
Two
Three
In column B the VBA gives me (in a single cell):
one,two,three
It doesn't give me all possible combinations permutations, it just changes what I typed in vertically down a column, and outputs the results horizontally.
1@cybernetic.nomad It looks like the Poster wants all the permutations associated with each combination – Gary's Student – 2019-01-15T00:16:44.270
ORDER is important. in the linked question, order is not important. – Forward Ed – 2019-01-15T00:24:19.293
2Because there are a finite number of rows (1 048 576) to excel you will be limited to only 9 entries if you wish all the permutations to be written out in a single column. If I did my math right, you will be looking at 986 409 permutations. 10 entries would give 9 864 100 which exceeds the number of available rows. – Forward Ed – 2019-01-15T00:27:58.487
1I'd be looking at nested loops in vba. Start by writing out all the single entries, then repeat the process starting with the first entry, and loop through the remaining letters, then bump to the next entry and loop through the remaining letters until all the 2 combinations are written. just keep repeating the pattern and eventually all will be written out. – Forward Ed – 2019-01-15T00:31:05.290
@ForwardEd, in that case, the output doesn't have to go vertically, if the output all goes into a single cell separated by , and | as in
one | one,two | two | two,one
, that would work for me too. – oshirowanen – 2019-01-16T19:07:55.423There is also a limitation to the number of Characters in a cell of a little over 32K. You will get further using a column than you will putting it into a single cell. Especially if each entry is more than 1 character long. – Forward Ed – 2019-01-16T23:41:30.110
another option you have is write out ever permutation and combination, and then delete the entries that have repeated entries. Though you will wind with fewer permissible entries as you will hit your row limit sooner due to the rows with repeats. – Forward Ed – 2019-01-16T23:43:53.037
@cybernetic.nomad, you are correct, I am after all permutations. I will try rewording the question. – oshirowanen – 2019-01-17T09:34:51.297
Why does it have to be a formula rather than VB? Being able to use actual loops you would be able to refer to common posts about permutation calculation for other langues. For the macro you just state it doesn't work but not what actually isn't working about it.
– Seth – 2019-01-17T10:06:43.523@Seth, I have stated that the macro does not work because when in input
one two three
, it outputsone, two, three
. It does not output all permutations. It does not have to be a formula, if it is VB, or even C#, I would be okay with that. – oshirowanen – 2019-01-17T18:47:25.7131
Here's a screen shot in case it rings a bell for an idea with any Excel functions or add-on features people may be familiar with: https://i.imgur.com/zTh37v6.png Perhaps there's a PowerShell that can do this, if I knew of something I'd try but this should be easy with a relation type query or join of the data in a table object or something to itself if applicable with some of those features.
– Pimp Juice IT – 2019-01-18T01:53:05.017