How to Count Occurrences in Entire Workbook in Excel

This post will guide you how to count number of occurrences in whole workbook in Excel 2013/2016 or Excel office 365. How do I count how many times a string is repeated in all worksheets in Excel. You may be want to count occurrences for the number of times a certain value matches across all worksheets in your current workbook. And you can do this by a formula based on the SUMPRODUCT  function, the COUNTIF function and the INDIRECT function in Excel.

General Formula:

The below general formula can help you to count occurrences in a certain range across the entire workbook in Excel. Like this:

=SUMPRODUCT(COUNTIF(INDIRECT(“‘”&mysheets&”‘!”&range),criteria))

Note: you need to put the names of your all worksheets(sheet1,sheet2,sheet3) into cells. And then select this range, clicking on the drop-down arrow along the formula bar and name this range as “mysheets”.

count occurrences in entire workbook1

Count Occurrences in Entire Workbook


Assuming that you have a data of list in your workbook, and this workbook has three worksheets. And those three worksheets are “Sheet1”,”Sheet2” and “Sheet3”that contain name lists in range B2:B6. And you want to count the number of occurrences of the product name “excel” within a specified range B2;B6 across those three worksheets. And you can use a formula based on the SUMPRODUCT function, the COUNTIF function and the INDIRECT function. Like this:

=SUMPRODUCT(COUNTIF(INDIRECT(“‘”&mysheet&”‘!B2:B6”),C1))

count occurrences in entire workbook2

Let’s See That How This Formula Works:

=”‘”&mysheet&”‘!B2:B6″

count occurrences in entire workbook3

You know that mysheet is a named range that contains “sheet1”,”sheet2” and “sheet3”. This formula will return an array result like this:

{“‘sheet1’!B2:B6″;”‘sheet2’!B2:B6″;”‘sheet3’!B2:B6”}

count occurrences in entire workbook4

=INDIRECT(“‘”&mysheet&”‘!B2:B6”)

The INDIRECT function can be used to convert each text value to a cell reference.

=COUNTIF(INDIRECT(“‘”&mysheet&”‘!B2:B6”),C1)

count occurrences in entire workbook7

The COUNTIF function can be used to count the number of occurrences the value(cell c1) in those range B2:B6 match the value “excel”. And it also returns an array result contains count values from each worksheet.

{2;2;2}

count occurrences in entire workbook6

Finally, the SUMPRODUCT function sums the above array results returned by the COUNTIF function.

Related Functions


  • Excel SUMPRODUCT function
    The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products.The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)…
  • Excel INDIRECT function
    The Excel INDIRECT function returns the cell reference based on a text string, such as: type the text string “A2” in B1 cell, it just a text string, so you can use INDIRECT function to convert text string as cell reference….
  • Excel COUNTIF function
    The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…

 

Related Posts

Case Sensitive Lookup with SUMPRODUCT and EXACT

Today, we will show you how to use SUMPRODUCT and EXACT to perform a case sensitive exact match. In this article, we provide a simple example to calculate bonus for employees whose names are case-sensitive. If you meet similar scenarios ...

Average per Week by Formula in Excel
Average per Week 1

We usually apply AVERAGE function or relevant functions to return average directly in Excel worksheet. But in some situations, only applying average relevant functions cannot figure out our problem. Sometimes we can create a formula with functions and mathematical operation ...

How to Sum if Equal to Many Items or A Range in Excel
How to Sum if Equal to Many Items 12

If we want to sum numbers from a range with criteria, we often select SUMIF of SUMIFS functions as the first choice to create a formula. The criteria can be a number or an array or a collection of some ...

How to Sum if Equal to X or Y in Excel
How to Sum if Equal to X or Y 19

In daily work, if we want to sum numbers from a range, and only sum the numbers which being equal to X or Y in the range, we can create a formula with Excel build-in functions to get the result. ...

How To Sum the Largest N Values in Excel

Sometimes we may want to sum the largest N numbers or top N numbers in a range. In this article, we will show you the method of “SUM the Largest N Numbers” by a simple formula which consist of SUMPRODUCT ...

How to Sum for Cell Contains Formula Only in Excel
How to Sum for Cell Contains Formula Only in Excel 9

Sometimes values are created by formulas in cells. If we want to sum values which are created by formulas from a range, but some values which are hardcoded also list in the same range, how can we filter out matched ...

How to Sum the Smallest N Values in Excel
How to Sum the Smallest N Values in Excel 15

Sometimes we may want to sum the first smallest N numbers in a range in Excel. In this article, we will show you the method of “SUM the Smallest N Numbers” by a simple formula which consist of SUMPRODUCT and ...

How to Sum by SUMPRDUCT with One Specific Criteria Multiple Columns in Excel
How to Sum by SUMPRDUCT with One Specific Criteria Multiple Columns in Excel1

Sometimes we may meet the case that to sum numbers based on one specific criteria. In this article, we will show you the method to resolve this problem by formula with the help of Excel SUMPRODUCT function. SUMPRODUCT can filter ...

How to Sum by SUMPRDUCT with Specific Criteria in Excel
How to Sum by SUMPRDUCT with Specific Criteria in Excel 15

Sometimes we may meet the case that to sum numbers based on two or more specific criteria. In this article, we will show you the method to resolve this problem by formulas with the help of Excel SUMPRODUCT function. SUMPRODUCT ...

How to Count Unique Numeric Values in a Range in Excel
count unique numberic values7

This post will guide you how to count unique numeric values in the given range in Excel 2013/2016 or Excel office 365. How do I count the unique numeric values in a list of data with some duplicate values using ...

Sidebar