# A question for Mr. GillesD

#### tomtom

##### Member
Mr. GillesD, a few posts down below is your resolution for eliminating combos from different groups of numbers. Your proposed key solution is If Not (B <= 5 And C >= 6 And D <= 10 And E >= 11) Then for rejecting the combinations with exactly 2 numbers in (1, 2, 3, 4, 5), 2 numbers in (6, 7, 8, 9, 10 ), and with 2 numbers in (11, 12, 13, 14, 15). Here, all numbers are < 15 and distributed in groups that accept procedure B <= 5 And C >= 6 , for example. I’m a bit confused with this solution because I can’t imagine how may look a similar code (or part of the macro - macro’s lines) for some other exclusions. For illustration, if I use your previously posted macro that makes all possible combinations for 6/49 and want to eliminate combos with exactly 2 numbers from (7, 15, 19,20), with 3 numbers from (1,12,13, 17, 18, 32, 35, 47,49) and one number from (2,4,8,15,33). Example for a combination that should be eliminated is 7,19,32,33,35,49. Here, I’m interested only in the macro’s line that eliminate these certain combinations like a line If Not (B <= 5 And C >= 6 And D <= 10 And E >= 11) Then in the earlier solution, since you already posted a VBA macro that makes all possible combos for 6/49.

#### GillesD

##### Member
Combinations to be designed

I do not remember the exact application the macro was intended for but in many cases, especially where actual numbers to be used are not known or may vary in future draws, it is easier to design the combinations using consecutive numbers (1 to 10 for example) or letters (A to J for example). Afterward, once the numbers are known, it is just a matter of replacing some values by others to get the real combinations. For example, by replacing #10 or J by 42, #9 or I by 39 and so on.

In your example with 18 numbers and three groups to take them from, it could be programmed using the actual numbers but most likely coding will be more difficult to develop and understand afterward and then to change it if the numbers change. The use of consecutive numbers and the subsequent replacement will be much simpler and faster to perform (although particular attention must be given when replacing numbers).

#### tomtom

##### Member
Re: Combinations to be designed

GillesD said:
I do not remember the exact application the macro was intended for but in many cases, especially where actual numbers to be used are not known or may vary in future draws, it is easier to design the combinations using consecutive numbers (1 to 10 for example) or letters (A to J for example). Afterward, once the numbers are known, it is just a matter of replacing some values by others to get the real combinations. For example, by replacing #10 or J by 42, #9 or I by 39 and so on.

In your example with 18 numbers and three groups to take them from, it could be programmed using the actual numbers but most likely coding will be more difficult to develop and understand afterward and then to change it if the numbers change. The use of consecutive numbers and the subsequent replacement will be much simpler and faster to perform (although particular attention must be given when replacing numbers).

In fact, for what I was thinking about is quite OK to use the consecutive letters instead of numbers. For example a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r. These 18 letters make some (I think exactly 18546) combinations. I believe that you already posted a comparable macro that can make all the combinations using these 18 letters. For me, the actual trouble is how to make that such macro during the procedure of making all 6/18 combinations rejects some (exact) of them. For example, that rejects combinations consisting of exactly (any) two letters from the group (b,f,j,k), any three from (e,h,m,o,q),and one from (a,c,r). (In this particular case, these three groups contain 12 letters out of all 18). The main difficulty (and the only one) I’m coming across here is how to count (or identify) exactly any 2 from (b,f,j,k), any 3 from (e,h,m,o,q),and 1 from (a,c,r).
In my opinion, such a macro may be not only a macro, but also powerful software. Making all 6/18, a lottery player may discard numerous, in his/her opinions based on a mixture of motives, unlikely to appear combinations from a variety of different groups and move toward to, let’s say, 50 or 100 for example, out of initial 18546.

#### GillesD

##### Member
Selection of combinations

tomtom,

First, the number of combinations for 6 numbers out of 18 is 18564, not 18546 (transposition error?).

Considering your example, that is exactly why consecutive numbers or letters can be used with some advantage. If you want to choose six numbers out of 12, let’s identify them as AA, BB to LL, you define the first group as AA, BB, CC and DD (from which you will pick 2), the second one as EE, FF, GG, HH and II (from which you will pick 3) and the last one as JJ, KK and LL (from which you will pick 1).

When you cycle through all combinations made out of N1, N2, N3, N4, N5 and N6, it is then easy to set up conditions to meet your requirements. These may be quite simple (sum of numbers = 150) or as complicated as you may want.

In your example, the conditions should be:
- for N2 <= DD
- for N3 >= EE and N5 <= II
- for N6 >= JJ

This will just generate combinations with 2 numbers (N1 and N2) from the group AA, BB, CC and DD, 3 numbers (N3, N4 and N5) from the group EE, FF, GG, HH and II and 1 number (N6) from the group JJ, KK and LL. It is then just a matter of replacing AA to LL by the actual numbers you want to use.

#### tomtom

##### Member
Re: Selection of combinations

GillesD said:
tomtom,

First, the number of combinations for 6 numbers out of 18 is 18564, not 18546 (transposition error?).

Considering your example, that is exactly why consecutive numbers or letters can be used with some advantage. If you want to choose six numbers out of 12, let’s identify them as AA, BB to LL, you define the first group as AA, BB, CC and DD (from which you will pick 2), the second one as EE, FF, GG, HH and II (from which you will pick 3) and the last one as JJ, KK and LL (from which you will pick 1).

When you cycle through all combinations made out of N1, N2, N3, N4, N5 and N6, it is then easy to set up conditions to meet your requirements. These may be quite simple (sum of numbers = 150) or as complicated as you may want.

In your example, the conditions should be:
- for N2 <= DD
- for N3 >= EE and N5 <= II
- for N6 >= JJ

This will just generate combinations with 2 numbers (N1 and N2) from the group AA, BB, CC and DD, 3 numbers (N3, N4 and N5) from the group EE, FF, GG, HH and II and 1 number (N6) from the group JJ, KK and LL. It is then just a matter of replacing AA to LL by the actual numbers you want to use.

Well, so far I can’t see logic in the procedure using “<=”, and that is simply because I’m too accustomed to the Excel’s COUNTIF function. In addition, even with some programming experience, I found VB a bit tricky. However, as there are many supportive books, most likely I will take some time to get a bit deeper into it.

I wish you Happy Easter Holidays.