You are here:

Excel/Counting the occurrences of a set of data



I have a datasheet with thousands of rows of data. I want to count the number of occurrences of a specific set of data sequenced in rows. For example:

In rows 2000 to 2005 I have the following data

Row      Data
2000      Ssa
2001      Ddf
2002      Egt
2003      Wfd
2004      Xhy
2005      Zlk

I need to know how many times this exact sequence happened in my data, keeping in mind similar data may have occurred in other cells but not in the same sequence which in this case shouldn't be counted.



Assume you data is in cells (A2:A1000) then


so since you are starting in A2, my first check is to

A2:A995   which is 994 rows.  each of the ranges in the subsequent sections must be 994 rows and must increment by 1.  so the formula first checks


if all of those are true, it will result in a 1 and if not, then a zero.

it progresses through the 994 rows and makes this count.  The result will be the total number of occurances where a sequence of 6 rows hold the values you specify in the sequence you specify.

Tested and worked for me.

You will just need to adjust the ranges to reflect the range you want to check.  

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.