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

Data Analysis

  • How To Perform and Interpret Regression Analysis in Excel
  • How to Create One and Two Variable Data Tables in Excel
  • How to count table rows in Excel
  • How to create Gauge Chart in Excel
  • How to create dynamic reference table name in Excel

References

  • LOOKUP function: Description, Usage, Syntax, Examples and Explanation
  • MATCH function: Description, Usage, Syntax, Examples and Explanation
  • How to get last row in numeric data in Excel
  • How to get address of first cell in range in Excel
  • Create hyperlink with VLOOKUP in Excel

Data Validations

  • Excel Data validation only dates between
  • Excel Data validation unique values only
  • How To Create Drop-down List in Excel
  • Data validation must not exist in list
  • Excel Data validation whole percentage only

Count rows that contain specific values in Excel

by

This tutorial shows how to Count rows that contain specific values in Excel using the example below;

Formula

=SUM(--(MMULT(--(criteria),TRANSPOSE(COLUMN(data)))>0))

Count rows that contain specific values in Excel

Explanation

To count rows that contain specific values, you can use an array formula based on the MMULT, TRANSPOSE, COLUMN, and SUM functions. In the example shown, the formula in G5 is:

{=SUM(--(MMULT(--(data=90),TRANSPOSE(COLUMN(data)))>0))}

where data is the named range B4:B12.

Note: this is an array formula and must be entered with control shift enter.

How this formula works

Working from the inside out, the logical criteria used in this formula is:

--(data=90)

where data is the named range B4:D12. This generates a TRUE / FALSE result for every value in data, and the double negative coerces the TRUE FALSE values to 1 and 0 to yield an array like this:

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

Like the original data, this array is 9 rows by 3 columns (9 x 3) and goes into the MMULT function as array1.

Array2 is derived with:

TRANSPOSE(COLUMN(data))

This is the tricky and fun part of this formula. The COLUMN function is used simply for convenience as a way to generate a numeric array of the right size. To perform matrix multiplication with MMULT, the column count in array1 (3) must equal the row count in array2.

COLUMN returns the 3-column array {2,3,4}, and TRANSPOSE changes this array to the the 3-row array {2;3;4}. MMULT then runs and returns a 9 x 1 array result:

=SUM(--({2;0;7;2;0;0;0;0;4}>0))

We check for non-zero entries with >0 and again coerce TRUE FALSE to 1 and 0 with a double negative to get a final array inside SUM:

=SUM({1;0;1;1;0;0;0;0;1})

In this final array, a 1 represents a row where the logical test (data=90) returned true. The total returned by SUM is a count of all rows that contain the number 90.

Literal contains

If you need to check for specific text values, in other words, literally check to see if cells contain certain text values, you can change the logic in the formula on this page to use the ISNUMBER and SEARCH function. For example, to count cells/rows that contain “apple” you can use:

=ISNUMBER(SEARCH("apple",data))

Post navigation

Previous Post:

How to use Excel CHOOSE Function

Next Post:

Customize Ribbon 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
  • Excel If, Nested If, And/Or Criteria Examples
  • Complete List of Excel Logical Functions, References and Examples
  • FALSE function: Description, Usage, Syntax, Examples and Explanation
  • Invoice status with nested if in Excel

Date Time

  • NETWORKDAYS.INTL function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate project start date based on end date in Excel
  • Get work hours between dates in Excel
  • HOUR function: Description, Usage, Syntax, Examples and Explanation
  • EOMONTH function: Description, Usage, Syntax, Examples and Explanation

Grouping

  • Categorize text with keywords in Excel
  • How to randomly assign people to groups in Excel
  • Calculate conditional mode with criteria in Excel
  • If cell contains one of many things in Excel
  • Group numbers at uneven intervals in Excel

General

  • How to create dynamic worksheet reference in Excel
  • Create dynamic workbook reference to another workbook in Excel
  • How to fill cell ranges with random text values in Excel
  • How to generate random number between two numbers in Excel
  • AutoFit Column Width, AutoFit Row Height in Excel
© 2025 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning