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

Data Analysis

  • Number and Text Filters Examples in Excel
  • Move chart to a separate worksheet in Excel
  • Get column index in Excel Table
  • Excel Pie Chart
  • Conditional Formatting Icon Sets Examples in Excel

References

  • How to get relative row numbers in a range in Excel
  • How to use Excel OFFSET function
  • How to create dynamic named range with OFFSET in Excel
  • To count total rows in a range in Excel
  • How to use Excel TRANSPOSE Function

Data Validations

  • Excel Data validation number multiple 100
  • Excel Data validation must contain specific text
  • Excel Data validation exists in list
  • Data validation must not exist in list
  • Excel Data validation don’t exceed total

Count total matches in two ranges in Excel

by

This tutorial shows how to Count total matches in two ranges in Excel using the example below;

Formula

=SUMPRODUCT(COUNTIF(range1,range2))

Explanation

If you want to compare two ranges, and count total matches between the two ranges, you can use a formula that combines the COUNTIF and  SUMPRODUCT functions.

Context

Suppose you have a “master” list of some kind, and also have another list that contains some of the same items. You want a formula that compares the values in the 2nd list to see how many of them appear in the first list. You don’t care about the order that the items — you just want to know how many items in list 2 appear in list 1.

Worked Example:   Count cells over 100 characters in Excel

Solution

The formula we are using in cell G7 is:

=SUMPRODUCT(COUNTIF(B5:B11,D5:D11))

Note that this formula does not care about the location or order of the items in each range.

Explanation

The COUNTIF function will count things in a range that meet your criteria. Normally, you would give COUNT if a range like A1:A10 and a simple criteria like “>10”. COUNTIF would then return the count of cells in A1:A10 that are greater than 10.

In this case however, we are giving COUNTIF a range for criteria. We aren’t using any logical operators, which means COUNTIF will check for equivalency (i.e. it behaves as if we used the equals (=) operator).

Worked Example:   Basic text sort formula in Excel

Because we give COUNTIF a range (also called an “array”) that contains 7 items, COUNTIF will return an array of 7 items as a result. Each item in the result array represents a count. In the example, this array that COUNTIF returns looks like this:

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

Now we simply need to add up the items in this array, which is a perfect job for SUMPRODUCT. The SUMPRODUCT function is a versatile function that handles arrays natively without any special array syntax.

Worked Example:   Get nth match with VLOOKUP in Excel

If you give SUMPRODUCT two or more arrays, it will multiple the arrays together, sum up the results, and return that number. In this case, we give SUMPRODUCT just one array, so it simply sums up the items in the array and returns 4 as the result.

Match across rows

If you want to compare two ranges or columns, and want to count matches at the row level (i.e. only count matches when the same item appears in the same position), you’ll need a different formula.

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

  • SWITCH function: Description, Usage, Syntax, Examples and Explanation
  • Not Equal To ‘<>‘ operator in Excel
  • Check multiple cells are equal in Excel
  • How to use Excel AND Function
  • Extract multiple matches into separate rows in Excel

Date Time

  • NETWORKDAYS function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate Next working/business day in Excel
  • How to show last updated date stamp in Excel
  • Add workdays no weekends in Excel
  • How to calculate nth day of year in Excel

Grouping

  • Group times into unequal buckets in Excel
  • Map text to numbers in Excel
  • Running count group by n size in Excel
  • Calculate conditional mode with criteria in Excel
  • Group numbers with VLOOKUP in Excel

General

  • How to get original number from percent change in Excel
  • Transpose: Switch ‘Rows to Columns’ or ‘Columns to Rows’ in Excel
  • How to calculate percentage discount in Excel
  • AutoRecover file that was never saved in Excel
  • Count cells that do not contain many strings in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning