简体   繁体   中英

Excel: =COUNTIF or =COUNTIFS referencing a range as their criteria

I have used a macro to get me a list of around 600,000 files (hosted on a server) that are then listed into an Excel sheet. From this list, I need to know how many DON'T meet a certain criteria and I have a few different statistics being calculated based on the files and their types (PNG, JPG, .DOC, PDF, etc). What I'm calculating or excluding from this list is changing often depending on what data I'm analyzing from this list. So that I don't have to constantly update a formula with a list of exclusions from this list, I'm trying to write a function that will just exclude a list in another column.

My current solution is a simple =COUNTIFS(A:A,{"<>","<>JPEG File","<>Outlook File", etc}). The "<>" is there because it keeps counting blank cells after the list if it is not included. I want to actually replace the COUNTIFS criteria part with a list of items in another column. I tried =COUNTIF(A:A,"<>"&C:C) and this doesn't work, but is returning a value equivalent to COUNTA, not actually excluding the items in the C column that I add (I think it's function in an AND capacity for the criteria and not as an OR). I tried doing a =COUNTA(A:A)-COUNTIF(A:A, C:C) but again, COUNTIF seems to be counting C:C as a list of AND criteria and not ORs.

The ideal would be if this actually worked: =COUNTIFS(A:A, "<>", A:A, "<>C:C") except that COUNTIFS doesn't allow a range as a criteria, so this obviously can't work.

Is there another solution that I'm just not seeing? Knowing myself, I wouldn't be surprised if it was actually super obvious and something I should have seen or I'm just misunderstanding something here.

=SUMPRODUCT(--(ISNA(MATCH(A:A,C:C,0))))-COUNTIF(A:A,"")

Where A:A is dataset and C:C is list to exclude. Example:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM