Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Excel Bar Chart
  • Remove Duplicates Example in Excel
  • Working With Tables in Excel
  • How to Use Solver Tool in Excel
  • Excel Pie Chart

References

  • Find closest match in Excel
  • Last row number in range
  • Excel Advanced Lookup using Index and Match Functions
  • Create hyperlink with VLOOKUP in Excel
  • How to get last row in numeric data in Excel

Data Validations

  • Excel Data validation date in specific year
  • Excel Data validation must contain specific text
  • Excel Data validation unique values only
  • Excel Data validation number multiple 100
  • Excel Data validation only dates between

Count matches between two columns in Excel

by

This tutorial shows how to Count matches between two columns in Excel using the example below;

Formula

=SUMPRODUCT(--(range1=range2))

Explanation

If you want to compare two columns and count matches in corresponding rows, you can use the SUMPRODUCT function with a simple comparison of the two ranges. For example, if you have values in B5:B11 and C5:C11 and you want to count any differences, you can use this formula:

=SUMPRODUCT(--(B5:B11=C5:C11))

How this formula works

The SUMPRODUCT function is a versatile function that handles arrays natively without any special array syntax. Its behavior is simple: it multiplies, then sums the product of arrays. In the example shown, the expression B5:B11 = C5:C11 will generate an array that contains TRUE and FALSE values like this:

Worked Example:   Check if range contains a value not in another range in Excel

{TRUE;TRUE;FALSE;TRUE;FALSE;FALSE;FALSE}

Worked Example:   SUMPRODUCT with IF in Excel

Note that we have 3 TRUE values because there are 3 matches.

In this state, SUMPRODUCT will actually return zero because TRUE and FALSE values are not counted as numbers in Excel by default. To get SUMPRODUCT to treat TRUE as 1 and FALSE as zero, we need to “coerce” them into numbers. The double negative is a simple way to do that:

--(B5:B11=C5:C11)

After coercion, we have:

Worked Example:   Count cells that contain text in Excel

{1;1;0;1;0;0;0}

With no other arrays to multiply, SUMPRODUCT simply sums the values and returns 3.

Count non-matching rows

To count non-matching values, you can reverse the logic like so:

=SUMPRODUCT(--(B5:B11<>C5:C11))

Post navigation

Previous Post:

44 Practical Excel IF function Examples

Next Post:

Large with criteria in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • XOR function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel OR Function
  • Complete List of Excel Logical Functions, References and Examples
  • FALSE function: Description, Usage, Syntax, Examples and Explanation
  • Excel If, Nested If, And/Or Criteria Examples

Date Time

  • Dynamic date list in Excel
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • DATEVALUE function: Description, Usage, Syntax, Examples and Explanation
  • Display Date is same month in Excel
  • How to get same date next year or previous year in Excel

Grouping

  • Group numbers with VLOOKUP in Excel
  • Running count group by n size in Excel
  • If cell contains one of many things in Excel
  • Group times into 3 hour buckets in Excel
  • Calculate conditional mode with criteria in Excel

General

  • How to Delete Cells, Row and Rows in Excel
  • Count cells that do not contain many strings in Excel
  • List worksheet index numbers in Excel
  • Sum by group in Excel
  • Using Existing Templates in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning