VBA that would spot an ID according to a group of Answers

jbesclapez

Active Member
Joined
Feb 6, 2010
Messages
275
Dear All (and Mike ;))

I have a column with a list of answers (IDs)
I have a table with 7 columns for the answers (some are empty) and an additional column with Result
The answer given in the first table have to be found in the second table to give the Result.
The order of the Answer is not important (Q002R03 + Q001R99 is the same then Q001R99 + Q002R03...)
You must read the table with AND attributes. So for example in the second row it is Q002R03 AND Q001R99 that gives Result B. But the Answers given do not have Q001R99 so result B cannot be expected as a result.

Please note that in the 8 you have Q006R12 + Q002R99 but no Q002R99 in the answer given. But still the result A is expected but coming from other "formulae".

The last table brings the expected results.


Answer given
Q001R01
Q002R03
Q003R05
Q004R12
Q005R10
Q006R12
Q009R11

<tbody>
</tbody>

Answer1Answer2Answer3Answer4Answer5Answer6Answer7Result
Q001R01A
Q002R03Q001R99B
Q004R12Q001R01Q003R05C
Q005R10D
Q005R10E
Q005R10F
Q006R12Q002R99A
Q006R12Q002R99G
Q001R01Q002R03Q003R05Q004R12Q005R10Q006R12A
Q001R01Q002R03Q003R05Q004R12Q005R10Q006R12Q009R11A

<tbody>
</tbody>


Result
A
C
D
E
F

<tbody>
</tbody>


Thanks for your time
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Maybe using Advanced Filter + a formula

Something like this

A
B
C
D
E
F
G
H
I
J
K
L
M
N
1
Answer given​
Result​
Answer1​
Answer2​
Answer3​
Answer4​
Answer5​
Answer6​
Answer7​
Result​
2
Q001R01​
A​
Q001R01​
A​
TRUE​
3
Q002R03​
C​
Q002R03​
Q001R99​
B​
4
Q003R05​
D​
Q004R12​
Q001R01​
Q003R05​
C​
5
Q004R12​
E​
Q005R10​
D​
6
Q005R10​
F​
Q005R10​
E​
7
Q006R12​
Q005R10​
F​
8
Q009R11​
Q006R12​
Q002R99​
A​
9
Q006R12​
Q002R99​
G​
10
Q001R01​
Q002R03​
Q003R05​
Q004R12​
Q005R10​
Q006R12​
A​
11
Q001R01​
Q002R03​
Q003R05​
Q004R12​
Q005R10​
Q006R12​
Q009R11​
A​

Type Result in C1

Leave N1 blank and enter this formula in N2
=SUMPRODUCT(--ISNUMBER(MATCH(E2:K2,$A$2:$A$8,0)))=COUNTA(E2:K2)

Select the range (E1:L11 in the data sample above)

Data > Advanced Filter
pick Copy to another location
List range: $E$1:$L$11
Criteria Range: $N$1:$N$2
Copy to: $C$1
check Unique records only
Ok

Hope this helps

M.
 
Upvote 0
I had time to try both solutions.
I am going with the one of Mike as it runs faster on my massive Sheet.

However, the formula was also interesting to know. Never though about it like that.

Thanks to both of you.
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top