Question

I'm working in Excel 2013. I've had a quick google for this, but I think my terminology might be wrong as I'm not finding a response that solves my exact problem.

I have a column of concatenated healthcare-related outcomes, such as:

"999 Emergency Ambulance By Co-op Admit Accident & Emergency! Admitted To Hospital"
"Advice Only"
"Admit to hospital"
"Medication prescribed"

I want to enter one formula in one cell that counts the records that EITHER contain "999" "Admit" OR "A&E" OR "Admission" for the ENTIRE column.

I don't want to have another column performing this count, I know the following works:

=IF(ISNUMBER(SEARCH("999",K2)),1,IF(ISNUMBER(SEARCH("ADMIT",K2)),1,IF(ISNUMBER(SEARCH("ADMISSION",K2)),1,0)))

But the formula I would need would replace the sum of the column that contained the above formula, negating the need for an extra column.

What I'm struggling with is that the other solutions I've seen would check the column for each condition and you'd end up with cells counted twice. As you can see in the above, some cells will contain "999" AND "Admit".

Apologies if this is a simple question!

Thanks in advance.

Était-ce utile?

La solution

You can use this formula:

=SUMPRODUCT(1*((NOT(ISERROR(SEARCH("999";A1:A4)))+NOT(ISERROR(SEARCH("Admit";A1:A4)))+NOT(ISERROR(SEARCH("Admission";A1:A4))))>0))

Or, as in your example, use Isnumber instead of NOT(ISERROR(

Depending on your regional settings you may need to replace field separator ";" by ","

Autres conseils

You can use MMULT here to avoid some repetition, i.e.

=SUMPRODUCT((MMULT(ISNUMBER(SEARCH({999,"Admit","A&E","Admission"},K2:K100))+0,{1;1;1;1})>0)+0)

Assumes data in the range K2:K100 - change as required

Note that there are 4 1s in {1;1;1;1} to match the 4 search terms - if you increase the number of search terms you need to increase the numbers of 1s

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top