This question has been asked before and the answer always seems to be to add together two COUNTIF
s. This is fine for most applications, but won't work for me.
I have a column that can contain 0, 1 or more valid tokens as well as 0, 1 or more invalid tokens. For example, if A, B and C are valid tokens and D, E and F are invalid, I might have data that looks like in the "Token" column in the table below. I've added the "ValidCount" and "Valid" columns to show the different interpretations.
╔══════╦═══════╦════════════╦═══════╗ ║ Row# ║ Tokens║ ValidCount ║ Valid ║ ╠══════╬═══════╬════════════╬═══════╣ ║ 1 ║ A, E ║ 1 ║ True ║ ║ 2 ║ ║ 0 ║ False ║ ║ 3 ║ B ║ 1 ║ True ║ ║ 4 ║ F, G ║ 0 ║ False ║ ║ 5 ║ A,B,C ║ 3 ║ True ║ ║ 6 ║ C ║ 1 ║ True ║ ╚══════╩═══════╩════════════╩═══════╝
I can count instances of valid tokens with the following (where the raw data is on a sheet called "Raw", the tokens are in column AD and the token in question is in cell A30 on the sheet called "Summary":
=COUNTIF(Raw!$AD$2:$AD$79,CONCATENATE("*",Summary!$A30,"*"))
The trouble is that if I do this for each valid token and sum them, I end up counting the total number of valid tokens. What I want to do is get the number of cells with at least one valid token. Using the example above, the correct answer is 4, not 6.
What I want to do is use an OR
function like this:
=COUNTIF(Raw!$AD$2:$AD$79,OR(CONCATENATE("*",Summary!$A30,"*"),CONCATENATE("*",Summary!$A31,"*"),[...snip...]))
but this gives 0.
Is there a way to do this? Ideally without resorting to VBA.