Microsoft Excel - Count - Count the number of errors in a range

Sample data:

1
2
#REF!
3
#REF!
5

Count the number of errors in a range

=SUM(IF(ISERROR(A1:A6),1))

returns 2.