I am in need of advice on how to generate all the possible combinations of 5 numbers, e.g. 1,2,3,4,5. Then 2,3,4,5,1 and so on, in a series of excel columns and rows. Also for 6 numbers etc. Thanks for suggestions...John
I am in need of advice on how to generate all the possible combinations of 5 numbers, e.g. 1,2,3,4,5. Then 2,3,4,5,1 and so on, in a series of excel columns and rows. Also for 6 numbers etc. Thanks for suggestions...John
Are you wanting 2 digit numbers like 35 and 53 or are you wanting 5 digit numbers?
<---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.Ron W
Thanks. You are right. I am after permutations. Any solution is welcome. ..
permutations not combinations! eg
123 has 1 combination of 3 but 6 permutations
123
321
132
312
213
231
is it always a series?
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and now happily retired
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
this workbook does it but i dont know if it will run on mac 2011
Thanks Martin. It's throwing up an error in the macro, screenshot attached. Any fix for that?
no idea its probably an office 2011 thing works fine in 2007
what did you put in it?
I was just opening the macro. Probably a mac problem. I'll check on my wife's PC tomorrow and let you know. Thanks v much.
I did this manually.
First, I entered 11111 in A1 and selected A1. I then went to Fill, Series. Select columns, selected Columns and end value of 55555 then OK. This filled column a with all possible numbers of 5 digits that could be formed by the digits 1,2,3,4,5 and also 0,6,7,8,9
I then used Find and one at a time found 0, selected All then deleted all numbers that had a 0. This I repeated for numbers 6, 7, 8, 9 This left me with numbers that only had the digits from 1 to 5.
I selected column A and then the Data tab, Text to columns, Fixed width and set the delimiters between each digit. Clicked finish and this separated the numbers into 5 columns.
I then sorted all the remaining numbers from smallest to largest. I then used the COUNTIF to count the number of 1's 2's 3's, 4's and 5's in each row. =countif($a1:$e1,1) =countif($a1:$e1,2) =countif($a1:$e1,3) =countif($a1:$e1,4) and =countif($a1:$e1,5) in the cells G1:K1 and copied down the length of the data.
Next step was to use in L1 =sum(G1:k1) and copied down the length of the data. All data was selected and sorted on column L. All rows that didn't total 5 were deleted. This left only rows of 5 digits with the digits 1 to 5 with no duplicates. (124 rows)
Using the above for 6 digits, I ended up with 720 6 digit combinations.
Thank you @ newdoverman. This is a great solution, for me, as it explains all the steps that would probably be written in a macro in order to achieve the outcome. I've enjoyed following the step by step logic!
slighly different manual method
123456 in cell a1
use series fill columns increment 1 stop value 654321
then in b1
=SUMPRODUCT(--ISNUMBER(SEARCH({"1","2","3","4","5","6"},A1)))=6
double click the fill handle to fill down
copy paste special values over the formulas to remove them
filter on true
copy paste visible rows to new sheet
then text to columns fixed width on that
alternative to copying visible rows is to sort by column b descending
go down to first false in this case it would be a721
click the row number to select the row then ctrl+shift+down arrow to select all the false then delete
Last edited by martindwilson; 12-07-2013 at 11:11 PM.
Thanks very much @ martindwilson. I shall have a play with that as well - appreciated![]()
i just tried the xlsm i uploaded and i get the same error must be a version thing
try the xls version instead
ITS LIMITED BY ROWS SO THE MOST YOU'LL GET IS 1-8
also attached is 1-5 1-6 1-7 1-8 done also included is the same thing with text
you can use that as a template so say you wanted
12 35 67 89 41
you can find replace each letter with one of those
Last edited by martindwilson; 12-07-2013 at 11:48 PM.
Hi, Mr MartinWilson and Mr Newdoverman,
I'm sorry to say something in this post, I'm not an expert, I'm just a old man that is trying to learn excel..
I was reading about Permutation Code that Mr martinwilson supplied to Mr Hazzahanna, and the error
Suppossedly Is caused by the Excel version, according to various links,![]()
If N > Cells.Count Then GoTo DataError
That Line have to be replaced by CountLarge something word
suppossedly the older excel just manage less than 2147483647 ( my god its a lot!)![]()
If N > Cells.CountLarge Then GoTo DataError
and the newer excel handle 17179869184 cells.
Thank you, and I apologies if i mess a Forum rule.
Best Regards from Miami.
David
Hi, Mr MartinWilson and Mr Newdoverman,
Here is the link (sorry, forgot)
http://answers.microsoft.com/en-us/o...1-522bfe373d25
Best Regards from Miami
David
Last edited by david gonzalez; 12-08-2013 at 12:35 AM. Reason: Sorry, i forgot the code was url
@ david gonzalez thanks for that link ,replacing that line of code has done the trick for xlsm, good find
ok here is the modified work book
ive remmed out the old code line and added the new
Thank you @ martindwilson. Your macro works perfectly! I am really grateful to you for this neat solution. I will use for organising team workshops, whereby I arrange several permutations of group members to discuss topics, sequentially, and without meeting the same group members. Many thanks!![]()
Hi, Mr MartinWilson and Mr Newdoverman,
Thank you very much and your welcome.
Best Regards from Miami
David
Thanks for the link....interesting!
Thank you for the feedback. It was fun to see an answer slowly take shape one step at a time.
Thank you all for contributing solutions to this problem I have had for a while. I will check it out and seek your advice on how to finesse the solution for my training groups. Regards..J
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks