How to count number of cells whose contents start with 0?

925 Views Asked by At

I need to count how many cells are in a column, but all the content of the cells are id numbers that start with 0. For example, a column of numbers say A1-A3 looks like:

0253980
0253980  
0250137  

The answer should be "3" but =COUNT(A1:A3) produces "0". This is because the id numbers commence 0. I do not want to convert the numbers because they will be part of other queries later where people need to copy and paste thousands of id numbers into a program which will not work if the 0 is removed.

Is is possible to do a count on these cells?

1

There are 1 best solutions below

1
On

In Excel what look like numbers are text strings when they start 0 (in general, though numbers may be displayed as preceded with one or more zeros through formatting - all credit to @chris neilsen for reminding me of that!), since Excel automatically strips leading zeros from numeric values. =COUNT:

counts the number of cells that contain numbers, and counts numbers within the list of arguments. Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers.

so is not suitable for text strings. However =COUNTA:

Counts the number of cells that are not empty and the values within the list of arguments. Use COUNTA to count the number of cells that contain data in a range or array.

Hence fortunately the solution is very simply to substitute one function for the other and :

=COUNTA(A1:A3)