Complicated VBA with 2 Conditions, 1 = Row target Sum, 2= Single number in the row</SPAN></SPAN>
Hello,</SPAN></SPAN>
I am looking some specific solution I will try my best to explain here, if it is not clear. Please ask any question I will try to make it clearer</SPAN></SPAN>
There is total 9 Numbers, which are as follow---> 1, 2, 3, 4, 5, 6, 7, 8, and 9, Column A</SPAN></SPAN>
Out of 9 numbers any quantity of numbers can be used in the row to make combinations of 7 in the each rows in the columns D:J</SPAN></SPAN>
I want also a VBA that can apply the following conditions...</SPAN></SPAN>
Condition 1- as per given example row target sum could be selected as desired in the column K (in this example selected sum = 33)</SPAN></SPAN>
Condition 2- as per example given single number 0 to 7 can be used desired in the column L </SPAN></SPAN>
Explanations of condition-2, for examples...</SPAN></SPAN>
L4=0 in the row D4:J4 used 1=3 times, 7=2 times, 8=2 times (Used Single number 0 time)</SPAN></SPAN>
L5=1 in the row D5:J5 used 1=2 times, 4=2 times, 9=2times (5 is used as a single number so far 1 number is single used) same condition is applied to row L5:L11</SPAN></SPAN>
L12=2 in the row D12:J12 used 1=2 times, 8=3 times (3 & 4 is used as a single number so far 2 numbers are single used) same condition is applied to row L12:L18</SPAN></SPAN>
L19=3 in the row D12:J12 used 1=2 times, 9=2 times (3, 6 & 9 is used as a single number so far 3 numbers are single used) same condition is applied to row L19:L37</SPAN></SPAN>
And same you will see for 4, 5 & 7 </SPAN></SPAN>
Example </SPAN></SPAN>
Thank you all</SPAN></SPAN>
Excel 2000</SPAN></SPAN>
Regards,</SPAN>
Moti</SPAN>
Hello,</SPAN></SPAN>
I am looking some specific solution I will try my best to explain here, if it is not clear. Please ask any question I will try to make it clearer</SPAN></SPAN>
There is total 9 Numbers, which are as follow---> 1, 2, 3, 4, 5, 6, 7, 8, and 9, Column A</SPAN></SPAN>
Out of 9 numbers any quantity of numbers can be used in the row to make combinations of 7 in the each rows in the columns D:J</SPAN></SPAN>
I want also a VBA that can apply the following conditions...</SPAN></SPAN>
Condition 1- as per given example row target sum could be selected as desired in the column K (in this example selected sum = 33)</SPAN></SPAN>
Condition 2- as per example given single number 0 to 7 can be used desired in the column L </SPAN></SPAN>
Explanations of condition-2, for examples...</SPAN></SPAN>
L4=0 in the row D4:J4 used 1=3 times, 7=2 times, 8=2 times (Used Single number 0 time)</SPAN></SPAN>
L5=1 in the row D5:J5 used 1=2 times, 4=2 times, 9=2times (5 is used as a single number so far 1 number is single used) same condition is applied to row L5:L11</SPAN></SPAN>
L12=2 in the row D12:J12 used 1=2 times, 8=3 times (3 & 4 is used as a single number so far 2 numbers are single used) same condition is applied to row L12:L18</SPAN></SPAN>
L19=3 in the row D12:J12 used 1=2 times, 9=2 times (3, 6 & 9 is used as a single number so far 3 numbers are single used) same condition is applied to row L19:L37</SPAN></SPAN>
And same you will see for 4, 5 & 7 </SPAN></SPAN>
Example </SPAN></SPAN>
Book1 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | ||||||||||||||
2 | Condition 1 | Condition 2 | ||||||||||||
3 | Numbers | n1 | n2 | n3 | n4 | n5 | n6 | n7 | Row Sum | Use Single Numbers In The Row | ||||
4 | 1 | 1 | 7 | 8 | 7 | 1 | 1 | 8 | 33 | 0 | ||||
5 | 2 | 1 | 1 | 4 | 4 | 9 | 9 | 5 | 33 | 1 | ||||
6 | 3 | 1 | 7 | 7 | 1 | 7 | 9 | 1 | 33 | 1 | ||||
7 | 4 | 1 | 8 | 1 | 4 | 8 | 4 | 7 | 33 | 1 | ||||
8 | 5 | 2 | 2 | 8 | 1 | 6 | 6 | 8 | 33 | 1 | ||||
9 | 6 | 2 | 3 | 2 | 3 | 5 | 9 | 9 | 33 | 1 | ||||
10 | 7 | 4 | 1 | 8 | 4 | 8 | 7 | 1 | 33 | 1 | ||||
11 | 8 | 9 | 3 | 5 | 1 | 9 | 1 | 5 | 33 | 1 | ||||
12 | 9 | 1 | 3 | 8 | 4 | 1 | 8 | 8 | 33 | 2 | ||||
13 | 3 | 3 | 3 | 6 | 8 | 8 | 2 | 33 | 2 | |||||
14 | 4 | 6 | 3 | 4 | 9 | 4 | 3 | 33 | 2 | |||||
15 | 5 | 7 | 1 | 5 | 5 | 5 | 5 | 33 | 2 | |||||
16 | 7 | 2 | 2 | 8 | 2 | 4 | 8 | 33 | 2 | |||||
17 | 8 | 3 | 3 | 1 | 3 | 7 | 8 | 33 | 2 | |||||
18 | 8 | 4 | 1 | 4 | 6 | 4 | 6 | 33 | 2 | |||||
19 | 1 | 3 | 1 | 9 | 6 | 4 | 9 | 33 | 3 | |||||
20 | 3 | 3 | 9 | 1 | 6 | 5 | 6 | 33 | 3 | |||||
21 | 3 | 5 | 6 | 9 | 3 | 5 | 2 | 33 | 3 | |||||
22 | 3 | 6 | 4 | 8 | 3 | 1 | 8 | 33 | 3 | |||||
23 | 3 | 6 | 1 | 9 | 6 | 5 | 3 | 33 | 3 | |||||
24 | 4 | 1 | 9 | 6 | 3 | 9 | 1 | 33 | 3 | |||||
25 | 4 | 4 | 7 | 7 | 2 | 1 | 8 | 33 | 3 | |||||
26 | 4 | 5 | 3 | 6 | 5 | 5 | 5 | 33 | 3 | |||||
27 | 5 | 1 | 6 | 6 | 2 | 8 | 5 | 33 | 3 | |||||
28 | 5 | 4 | 3 | 5 | 7 | 3 | 6 | 33 | 3 | |||||
29 | 6 | 4 | 1 | 6 | 7 | 7 | 2 | 33 | 3 | |||||
30 | 6 | 5 | 1 | 4 | 8 | 1 | 8 | 33 | 3 | |||||
31 | 6 | 9 | 2 | 1 | 1 | 8 | 6 | 33 | 3 | |||||
32 | 7 | 3 | 4 | 7 | 3 | 8 | 1 | 33 | 3 | |||||
33 | 7 | 4 | 5 | 2 | 4 | 5 | 6 | 33 | 3 | |||||
34 | 8 | 1 | 9 | 5 | 5 | 4 | 1 | 33 | 3 | |||||
35 | 8 | 8 | 4 | 1 | 6 | 3 | 3 | 33 | 3 | |||||
36 | 9 | 2 | 7 | 1 | 9 | 1 | 4 | 33 | 3 | |||||
37 | 9 | 3 | 9 | 1 | 1 | 6 | 4 | 33 | 3 | |||||
38 | 1 | 5 | 5 | 8 | 6 | 5 | 3 | 33 | 4 | |||||
39 | 1 | 5 | 7 | 5 | 2 | 5 | 8 | 33 | 4 | |||||
40 | 3 | 9 | 6 | 8 | 3 | 1 | 3 | 33 | 4 | |||||
41 | 4 | 3 | 3 | 3 | 5 | 6 | 9 | 33 | 4 | |||||
42 | 6 | 5 | 3 | 7 | 5 | 5 | 2 | 33 | 4 | |||||
43 | 7 | 9 | 5 | 2 | 2 | 6 | 2 | 33 | 4 | |||||
44 | 8 | 6 | 9 | 7 | 1 | 1 | 1 | 33 | 4 | |||||
45 | 1 | 1 | 9 | 5 | 8 | 6 | 3 | 33 | 5 | |||||
46 | 1 | 7 | 1 | 8 | 3 | 9 | 4 | 33 | 5 | |||||
47 | 1 | 8 | 7 | 5 | 3 | 7 | 2 | 33 | 5 | |||||
48 | 2 | 2 | 9 | 1 | 8 | 6 | 5 | 33 | 5 | |||||
49 | 2 | 6 | 5 | 1 | 8 | 8 | 3 | 33 | 5 | |||||
50 | 2 | 8 | 5 | 5 | 3 | 1 | 9 | 33 | 5 | |||||
51 | 2 | 8 | 6 | 3 | 5 | 2 | 7 | 33 | 5 | |||||
52 | 2 | 9 | 4 | 2 | 3 | 7 | 6 | 33 | 5 | |||||
53 | 3 | 1 | 2 | 9 | 7 | 3 | 8 | 33 | 5 | |||||
54 | 3 | 1 | 5 | 7 | 9 | 4 | 4 | 33 | 5 | |||||
55 | 3 | 4 | 5 | 7 | 9 | 4 | 1 | 33 | 5 | |||||
56 | 3 | 8 | 7 | 9 | 3 | 1 | 2 | 33 | 5 | |||||
57 | 4 | 2 | 5 | 9 | 8 | 1 | 4 | 33 | 5 | |||||
58 | 4 | 5 | 8 | 5 | 3 | 1 | 7 | 33 | 5 | |||||
59 | 4 | 6 | 6 | 2 | 1 | 9 | 5 | 33 | 5 | |||||
60 | 5 | 3 | 4 | 1 | 7 | 8 | 5 | 33 | 5 | |||||
61 | 5 | 4 | 3 | 8 | 9 | 3 | 1 | 33 | 5 | |||||
62 | 5 | 6 | 2 | 8 | 2 | 3 | 7 | 33 | 5 | |||||
63 | 5 | 6 | 8 | 3 | 2 | 5 | 4 | 33 | 5 | |||||
64 | 5 | 9 | 5 | 4 | 6 | 1 | 3 | 33 | 5 | |||||
65 | 6 | 4 | 5 | 3 | 5 | 9 | 1 | 33 | 5 | |||||
66 | 6 | 4 | 7 | 1 | 9 | 5 | 1 | 33 | 5 | |||||
67 | 6 | 4 | 7 | 4 | 8 | 3 | 1 | 33 | 5 | |||||
68 | 6 | 5 | 3 | 7 | 1 | 4 | 7 | 33 | 5 | |||||
69 | 6 | 9 | 4 | 3 | 4 | 2 | 5 | 33 | 5 | |||||
70 | 7 | 2 | 8 | 2 | 3 | 6 | 5 | 33 | 5 | |||||
71 | 7 | 8 | 4 | 2 | 2 | 1 | 9 | 33 | 5 | |||||
72 | 8 | 2 | 5 | 6 | 1 | 3 | 8 | 33 | 5 | |||||
73 | 8 | 3 | 4 | 9 | 1 | 7 | 1 | 33 | 5 | |||||
74 | 8 | 5 | 1 | 7 | 3 | 4 | 5 | 33 | 5 | |||||
75 | 9 | 2 | 6 | 4 | 6 | 5 | 1 | 33 | 5 | |||||
76 | 2 | 5 | 4 | 7 | 8 | 6 | 1 | 33 | 7 | |||||
77 | 2 | 8 | 6 | 3 | 1 | 4 | 9 | 33 | 7 | |||||
78 | 4 | 5 | 7 | 1 | 6 | 2 | 8 | 33 | 7 | |||||
79 | 5 | 6 | 2 | 7 | 8 | 4 | 1 | 33 | 7 | |||||
80 | 6 | 2 | 7 | 5 | 8 | 1 | 4 | 33 | 7 | |||||
81 | 6 | 5 | 4 | 1 | 7 | 2 | 8 | 33 | 7 | |||||
82 | 8 | 4 | 6 | 7 | 1 | 5 | 2 | 33 | 7 | |||||
83 | 9 | 4 | 8 | 1 | 6 | 3 | 2 | 33 | 7 | |||||
84 | ||||||||||||||
85 | ||||||||||||||
Sheet6 |
Thank you all</SPAN></SPAN>
Excel 2000</SPAN></SPAN>
Regards,</SPAN>
Moti</SPAN>
Last edited: