Home » excel » if statement – How to use IF and SUM in excel to count unique entries in a row?

# if statement – How to use IF and SUM in excel to count unique entries in a row?

Questions:

Basically I have a large set of data in excel, and I was wondering how to count across a row how many cells are not #N/A?? I think it should be possible with IF and SUM but I’m not entirely certain.

To count all values except blanks and #N/A errors try COUNTIFS like this for data in row 2

`=COUNTIFS(2:2,"<>#N/A",2:2,"<>")`

If you don’t want to count duplicates then this version will give you a count of all different values (except blanks and errors)

`=SUM(IF(1-ISERROR(2:2),(2:2<>"")/COUNTIF(2:2,2:2&"")))`

that’s an “array formula” that needs to be confirmed with CTRL+SHIFT+ENTER

Note that the first formula uses COUNTIFS function and therefore will not work in versions of excel before 2007 – this is an alternative that will work in those versions

`=COUNTA(2:2)-COUNTIF(2:2,"#N/A")`

Try using `=COUNTIF(RANGE, VALUE)`, here’s an example that will count the numer

``````=COUNTIF(A:A, "Yes")
``````

or

``````=COUNTIF(A1:D16, "Yes")
``````

To count the cells that contain a value (I.E., are not empty) then use ``=COUNTA(A:A)`

``````=COUNTIF(\$A\$2:\$A2,A2)>1