简体   繁体   中英

Excel - VLOOKUP or COUNTIF to count Matches from 2 Columns?

I'm trying to get a count of matches from two columns. Let's say I have a table with the following data.

Cars

In column A I have colours of cars e.g. Red, Yellow, Black, Green
In column B I have the type of car e.g. Diesel, Automatic, Manual

I want a count of all red cards that run on diesel so which function would I use?

Column A has 3 red cars
Column B has 6 diesel cars in total but only 1 of the red cars is a diesel.

I've tried :

=COUNTIF(A2:A10,"Red")+COUNTIF(B2:B10,"Diesel")

But it gives a combined count of all red cars and all diesel cars (9), not all red diesel cars, which should be 1.

您可以使用=COUNTIFS()公式:

=COUNTIFS(A1:A10,"Red",B1:B10,"Diesel")

You choud do an operation for each row, and sum all.

公式

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