Reputation: 145
I'm looking for a formula to count the number of cells in a Range that are integers. I am using
=IF(ISNUMBER(VALUE(A2))=TRUE,1,0)
to find if the cell contains a number or not. I believe this can be achieved using INDIRECT() and SUM(). Could someone be kind enough to lead me in the right direction?
Upvotes: 0
Views: 8395
Reputation: 3410
perhaps
=COUNT(1/(INT(A1:A10)=A1:A10))
array entered with ctrl+shift+enter
Upvotes: 0
Reputation: 234715
This will do it:
=SUM(IF(ISNUMBER(A1:A4),IF(ROUND(A1:A4,0)-A1:A4=0,1,0)))
Where A1:A4 is the range.
It's an array formula, meaning you need to type Ctrl+Shift+Return when entering it into a cell.
Only integers will be included; other values (strings and numbers with decimal part) will be discounted. It works by comparing a number to its rounded value.
Upvotes: 2