Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: COUNTA Function Returns 1 with Invalid Reference Argument


View products that this article applies to.

This article was previously published under Q214322

↑ Back to the top


Symptoms

If you type an invalid cell reference as an argument for the COUNTA worksheet function, the result is 1. For example the following function returns 1 in A1.
   A1: =COUNTA(B0:b10)
				

NOTE: The second character of the first cell reference is the number zero.

↑ Back to the top


Cause

This problem occurs because the COUNTA function interprets the invalid reference as the #NAME? error value and the function counts this one error value. This behavior is by design of Microsoft Excel.

↑ Back to the top


Resolution

To resolve this problem and count the number of nonblank cells in a range, type a valid reference for the range in the COUNTA worksheet function.

↑ Back to the top


More information

The COUNTA worksheet function counts the number of cells that are not empty and counts the values in the list of arguments. Nonempty cells can contain text, numbers, or error values. The arguments of the COUNTA worksheet function can also be an array or a list. For example, the following function returns 3 because it counts a text string, a number, and an error value:
   A1: =COUNTA("hello",4,#N/A)
				

In the following example, the argument of the COUNTA worksheet function is evaluated as #NAME? because cell B0 is not defined, and the result of the COUNTA worksheet function that appears in A1 is 1.
   A1: =COUNTA(B0:B10)
				

You can see this behavior if you select B0:B10 in the formula bar and press F9 to evaluate the reference. The formula changes to the following:
   A1: =COUNTA(#NAME?)
				

Excel counts one nonblank item (an error value), and the answer is exactly 1.

NOTE: Use the COUNT worksheet function to count numbers only.

↑ Back to the top


References

For more information about COUNTA worksheet function, click Microsoft Excel Help on the Help menu, type COUNTA worksheet function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB214322, kbnofix, kbbug

↑ Back to the top

Article Info
Article ID : 214322
Revision : 3
Created on : 11/5/2003
Published on : 11/5/2003
Exists online : False
Views : 258