简体   繁体   中英

Compare two columns in excel

Hey, I have an excel document with columns A and B. Row A has 2595 values. Row B has 411 values.

I'm trying to figure out how I can compare these two columns by marking column C with the number of times we find a value(s) from row a.

For Example

COLUMN A           COLUMN B        COLUMN C
1                  1               1 (because we have one value of 1 from column A)
2                  2               1 (because we have one value of 2 from column A) 
3                  3               2 (because we have 2 threes from column A) 
3                  4 
4                  5
5                  6               2 (because there are two 6's in column A) 
6                  7               0 (because there are no 7's in column A)
6

I'm sure you can see where I'm going with this but for the life of me I cannot figure out how to do this, I've been searching around all morning. Help!

If needed I can supply the excel document.

You can use COUNTIF . If A1:A8 is your search criteria, B1 is the value you're currently processing, C1 would be:

=COUNTIF(A1:A8;B1)

You can use the COUNTIF function

Column A    Column B    Column C                Answer
1          1            =COUNTIF($A$2:$A$9,B2) [1]
2          2            =COUNTIF($A$2:$A$9,B3) [1]
3          3            =COUNTIF($A$2:$A$9,B4) [2]
3          5            =COUNTIF($A$2:$A$9,B5) [1]
4          6            =COUNTIF($A$2:$A$9,B6) [2]
5          7            =COUNTIF($A$2:$A$9,B7) [0]
6           
6

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