Generating Combinations

S

Stella

I'm trying to do the following _without_ getting involved in complicated
macros ( -I'm still quite a newbie)
I need to produce a sequential list of all the ~53k combinations of any 5
from 25 i.e.
Row 1 = 1,2,3,4,5 across 5 columns
Row 2 = 1,2,3,4,6 across 5 columns etc.
When column 5 reaches 25 column 4 gets incremented by 1 & so that
Row = 1,2,3,5,6
and so on until the last row = 21,22,23,24,25

(hope I've explained it properly)

Help appreciated

TIA

Stella
 
B

Bernard Liengme

Please tell a nosey old man what, pray, are you going to do with 53,000 rows
of data when you get them. It will make boring reading.
You will need VBA for this.
Bernard
 
S

Stella

Hi Bernard,
Thanks for your nice [and quick, or is that quirky?] response
What does it matter why I need it - is it a rule of this NG that posters
posing questions have to explain why they need answers to problems?
Now then , can you answer the question or not?
Luv Ya
Stella
 
K

Ken Wright

Sometimes just curiosity and other times it can save an awful lot of needless
work if we know what the end game is and can often suggest a much simpler neater
way of achieving the ultimate aim. Either way that is the prerogative of the
person being asked for help. When you are the one doing the asking, common
courtesy would generally lead to restraint before making that kind of a reply.

Had you read Bernard's reply completely you would see that the onus is now on
you for where you want to go, as in order to achieve what you need Bernard has
told you that you will need VBA, whereas you stated you did not want to use
Macros. Ball is now in your court as to whether you want to change your mind
and use macros or not.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :)
----------------------------------------------------------------------------



Stella said:
Hi Bernard,
Thanks for your nice [and quick, or is that quirky?] response
What does it matter why I need it - is it a rule of this NG that posters
posing questions have to explain why they need answers to problems?
Now then , can you answer the question or not?
Luv Ya
Stella


Bernard Liengme said:
Please tell a nosey old man what, pray, are you going to do with 53,000 rows
of data when you get them. It will make boring reading.
You will need VBA for this.
Bernard
 
S

Stella

Hi ,

My name is Paul and I am replying to these follow-ups on behalf of and
with the knowledge of the original poster, Stella.
May I first say that when Stella posted her original question she was
putting in her own time over the weekend. on a project and the last thing
she needed was the sort of responses that she received.[ BTW, and for info,
she needed to generate a list of possibles for an application concerning
*What If* scenarios -but I agree with her that I do not see how this was
pertinent to the problem posed]

In your case , Ken, why do you choose to have a go at Stella's response to
Bernard and yet say nothing about his response ? By his own admission , he's
a *nosey old man* and, in any event, is not giving the correct info. You
seem to have jumped to the conclusion that Stella did not read all of his
response but did you? [you seem to assume that Bernard is correct re: the
use of VBA- but more of that later]

Bernard's comments come across as a patronizing, looking-down-his-nose, *Now
pray tell me young lady why......*, approach. Furthermore by stating that it
*will make boring reading* he's obviously showing that he's not there to
help but just to make some very unhelpful comments - something you seem to
condone.

I sometimes get the feeling that a clique has been formed around the
so-called experts that respond to these NGs, especially those who put MVP
( or something similar) behind their names. Some of them seem to have become
arrogant - especially when responding to questions from newbies.
I'm reminded of the situation some 20-25 years ago when PCs first appeared
and the main-frame guys just couldn't handle people like *Old Fred from
stores talking about bits, bytes, ROM & RAM etc.*

Now for the actual problem that Stella posed. It is perfectly POSSIBLE to
achieve what she was looking for WITHOUT using VBA.[ I've already given her
the solution and it took me less than 25 minutes]
I was solving problems like that more than 15 years ago using apps like
Quattro and long before the advent of VBA.
Another example: recently a bored colleague who knows absolutely nothing
about VBA managed to annoy his boss by printing out all 3 from 49 lotto
combinations [18,424 of them] on several reams of paper.When I asked him to
show me how he did it , it was simply by using clever cell formulae with no
macros at all.

So where does that leave you my MVP friend? Do you still insist that
Stella's problem can only be solved by the use of VBA?


Paul
p.p Stella




Ken Wright said:
Sometimes just curiosity and other times it can save an awful lot of needless
work if we know what the end game is and can often suggest a much simpler neater
way of achieving the ultimate aim. Either way that is the prerogative of the
person being asked for help. When you are the one doing the asking, common
courtesy would generally lead to restraint before making that kind of a reply.

Had you read Bernard's reply completely you would see that the onus is now on
you for where you want to go, as in order to achieve what you need Bernard has
told you that you will need VBA, whereas you stated you did not want to use
Macros. Ball is now in your court as to whether you want to change your mind
and use macros or not.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

-------------------------------------------------------------------------- --
It's easier to beg forgiveness than ask permission :)
-------------------------------------------------------------------------- --



Stella said:
Hi Bernard,
Thanks for your nice [and quick, or is that quirky?] response
What does it matter why I need it - is it a rule of this NG that posters
posing questions have to explain why they need answers to problems?
Now then , can you answer the question or not?
Luv Ya
Stella


Bernard Liengme said:
Please tell a nosey old man what, pray, are you going to do with 53,000 rows
of data when you get them. It will make boring reading.
You will need VBA for this.
Bernard

I'm trying to do the following _without_ getting involved in complicated
macros ( -I'm still quite a newbie)
I need to produce a sequential list of all the ~53k combinations of
any
5
from 25 i.e.
Row 1 = 1,2,3,4,5 across 5 columns
Row 2 = 1,2,3,4,6 across 5 columns etc.
When column 5 reaches 25 column 4 gets incremented by 1 & so that
Row = 1,2,3,5,6
and so on until the last row = 21,22,23,24,25

(hope I've explained it properly)

Help appreciated

TIA

Stella
 
S

Sandy Mann

Stella said:

Now for the actual problem that Stella posed. It is perfectly POSSIBLE to
achieve what she was looking for WITHOUT using VBA.[ I've already given her
the solution and it took me less than 25 minutes]

Paul
p.p Stella

And are you willing to share the solution with us Paul?

Regards

Sandy
 
J

JE McGimpsey

I'm not sure why Bernard and Ken thought this was a difficult problem to
implement in XL. It certainly doesn't require VBA.

Here's one way:

Put 1-5 in A1:E1, then

A2: =A1+(SUM(B1:E1)=94)
B2: =IF(SUM(C1:E1)=72,MAX(A1+2,MOD(B1,22)+1),B1)
C2: =IF(SUM(D1:E1)=49,MAX(A1+3,MOD(B1,22)+2,MOD(C1,23)+1),C1)
D2: =IF(E1=25,MAX(A1+4,MOD(B1,22)+3,MOD(C1,23)+2,MOD(D1,24)+1),D1)
E2: =MAX(A1+5,MOD(B1,22)+4,MOD(C1,23)+3,MOD(D1,24)+2,MOD(E1,25)+1)

Copy A2:E2 down to A53130:E53130
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top