Hi guys,

I´ve spent better part of the day trying to solve this baddie and I just cant get the result I´m looking for. So the question at hand is, Is there any function / VBA code that would solve this within, lets say, 4-5 lanes of coding (not counting declarations).

Desired outcome is Sum of column A when the condition is met. Condition consists of 6 variables (there is a pool of numbers from which you make the group which i need to scan, whether they are in group H1-H5; there may be 1-3 numbers to check against the group; and same applies for group O1-O5...checking 1 to 3 numbers if they are there or not). So lets set an example, I have numbers 11,12 for group H1-H5 and numbers 51, 81. I need a Sum of column A where all 4 numbers are present on relevant row - result for my example should be "1" if I´m not mistaken. Order is irrelevant.

Hopefully I was clear about the goal - so far best solution I came up with was huge pile of Ifs which is not optimal.

TAB:
A B C D H1 H2 H3 H4 H5 O1 O2 O3 O4 O5
1 0 0 0 77 66 11 12 56 21 51 81 42 72
0 1 0 0 22 55 88 23 78 31 61 91 52 82
1 0 0 0 33 66 99 45 89 41 71 32 62 92
0 1 0 0 11 44 77 12 56 21 51 81 42 72
1 0 0 0 22 55 88 23 78 31 61 91 52 82
0 1 0 0 33 66 99 45 89 41 71 32 62 92
1 0 0 0 77 44 11 66 56 21 51 81 42 72
0 1 0 0 22 55 88 23 78 31 61 91 52 82
1 0 0 0 33 66 99 45 89 41 71 32 62 92


Lets see what you can come up with - also solutions that take whole page in VBA editor is not optimal either (same as my Ifs). I need a code, that i can read and understand with ease even if i come to this file 2 years later.

Thx for trying

Soul