# 使用 Excel Countif 函數比對兩份資料

When comparing data from two sources, one should not assume that the one with more data is the population value and the one with less data is the sample value.

For example, if A is a list containing the names of 40 students in a class, and B is a manually filled list containing only 38 students, many people would directly use the A list, delete duplicate data from the B list, and hope to find the two missing students.

However, in reality, the result you get may not be exactly two students remaining, but could be more or less. This is mainly because the following factors need to be considered: the A list itself may contain duplicate values, the B list itself may also contain duplicate values, and the B list may not be a subset of the A list, but rather their intersection.

At this point, the best method is to use the COUNTIF function in Excel, first self-check the A list with =COUNTIF(A:A,A2) to make sure there are no duplicates; then self-check the B list with =COUNTIF(B:B,B2) to make sure there are no duplicates; and then use the two columns =COUNTIF(B:B,A2) and =COUNTIF(A:A,B2) to perform the check.