Explanation

In this example the goal is to count numbers longer than 15 digits with a formula.

TheCOUNTIF functionmay seem like this logical choice.

you could see this problem in the worksheet below.

COUNTIF counts are incorrect due to long number problem

All counts in column D areincorrect.

Each number in column B is unique, yet the count returned by COUNTIF suggests the numbers are duplicates.

This problem is related to how Excel handles numbers.

COUNTIF counts are incorrect due to long number problem

The counting problem mentioned above arises from this limit.

‘999999999999999999) or by formatting the cell(s) as Text before entering.

The solution is to use the SUM function or the SUMPRODUCT function, as explained below.

COUNTIF counts are incorrect due to long number problem

SUM function

One solution is to replace the COUNTIF formula with a formula that uses theSUM function.

This tells us the number 1234567891234567 occurs just once in the data.

Note: this formula must be entered with Control + Shift + Enter inLegacy Excel.

COUNTIF counts are incorrect due to long number problem

For more on this topic, seeWhy SUMPRODUCT?

COUNTIF can be used to count…

COUNTIF counts are incorrect due to long number problem

Excel formula: Count items in list

Excel formula: Count numbers with leading zeros

Excel formula: Count specific words in a range

Excel formula: Count cells that do not contain errors

Excel SUMPRODUCT function

Excel COUNTIF function

COUNTIF counts are incorrect due to long number problem