Fresh Excel Tips

Quick and Easy Excel Tips and Tutorials

How to count sets of cells located in two columns in Excel

For this example, we will attempt to count sets of cells located in two columns in Excel. What does this mean? In our example we have two columns with different values and we’d like to find out how often two sets of values appear adjacent to each other. You can look at the image and see that a and 4 appear together 2 times, but of course, what if you are working with lots of values? Here is how to check this using a formula. We will be using the SUMPRODUCT Function.

  1. Layout your data as shown in the picture or use your own layout.
  2. Select Cell C5 and enter the following formula: =SUMPRODUCT(–(A1:A5=”a”),–(B1:B5=4))
  3. You can modify this by changing the values a and 4 as well as changing the range of values it checks.

How to count sets of cells located in two columns in Excel

You should now be set!

How to count sets of cells located in two columns in Excel
  1. Use the COUNT function to count cells containing numeric data
  2. How to Use the COUNTA function to count cells containing text
  3. How to Use the COUNTBLANK function to count empty cells
  4. How to Use the COUNTA function to count cells containing data
  5. Use the ISODD and COLUMN functions to determine odd columns

3 Comments


  1. Nicole

    You give the formula using “-” before the ranges, yet I notice in the fx field it’s shown as “–”. I’ve seen other examples on the net using “–”. Which is it?



  2. Nicole

    Sorry it didn’t reproduce as typed, I mean the difference between what may be and “em” dash and a pair of shorter hypens. Thanks.



  3. Katie Piatt

    Fantastic - excellent tip, saved me loads of time.


Leave a Reply