Home » excel » excel – Count a 2D array within a range

excel – Count a 2D array within a range

Posted by: admin May 14, 2020 Leave a comment


I have a map that I want to separately count the patterns of different numbers.

Image Map

Without VB, I want to be able to create a dynamic counter that will be able to count the patterns of numbers.

For example:

I want to count how many times, even if it overlaps that this pattern occurs in the map

2 2
2 2

Counting I can see the pattern occurs six times but I’m struggling to create a simple array formula that will be able to do so

I’ve been told of success with and IF function with nested AND functions so I know it can be done without VB.

How to&Answers:

Use the formula


notice how the two areas are adjacent – one column offset from each other.

enter image description here

You can extend this to find two-by-two regions:


just be very careful about how the different ranges are offset.

An alternative way to write this which, I suspect, will be more efficient for large ranges is: