# How to Count Numbers Nth Digit Equals to Specific Number in Excel

This post will guide you how to count numbers where the Nth digit equal to a specific number in Excel 2013/2016 or Excel office 365. How do I count of numbers in a given range where the Nth digit is equal to a particular number using SUMPRODUCT function and the MID function in Excel.

## General Formula:

The below general formula can help you to count the numbers where the Nth digit equal to a given number in a given range of cells in Excel. Like this:

=SUMPRODUCT(–MID(range,digit,character)=”number”)

## Count Numbers Where The Nth Digit Equal To

Assuming that you have a data of list in range B2:B6, and you want to count numbers where the second digit equals to number “5”, and you can use a formula based on the SUMPRODUCT function and MID function. Like this:

=SUMPRODUCT(–(MID(B2:B6,2,1)=”5″)) Let’s See That How This Formula Works:

= MID(B2:B6,2,1) The MID function can be used to extract the number or character from the given text string. And if you want to get the second character or number from a given range B2:B6, and you can use the above formula. And the first argument is a cell range, and the second argument specifies the start position, and the third argument indicates that the number of characters you want from the specified position of the text. This formula returns an array result like this:

{“0″;”5″;”4″;”5″;”5”} This array results contain all the second digit from each cells in the given range B2:B6.

=MID(B2:B6,2,1)=”5″ The above array result will compare each value to “5” to generate a TRUE or FALSE result. And this formula also returned as an array result of TRUE and FALSE values. Like this:

{FALSE;TRUE;FALSE;TRUE;TRUE} =–(MID(B2:B6,2,1)=”5″) Then you need to use a double negative operator to convert TRUE or FALSE values to 1 and 0. It also returned an array result like:

{0;1;0;1;1} SUMPRODUCT function sums the numbers in the above array and returns 3.

### 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 MID function
The Excel MID function returns a substring from a text string at the position that you specify.The syntax of the MID function is as below:= MID (text, start_num, num_chars)…
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

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

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

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

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

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

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

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

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