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?

Posted by: admin May 14, 2020 Leave a comment

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.

How to&Answers:

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")

Answer:

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)

Answer:

When you want to “mark” the duplicates, use this in an empty column:

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

Puth the formula is row 2 and copy this all the way down to the last used row.

(What I usually do: Somewhere in column A, press [Ctrl]+[Down], to jump to the last item, then move sideways to the column where you want to put your formula in and put something e.g. an “X”. Then jump all the way up [Ctrl]+[Up], put the formula in row 2, copy it and press [Shift]+[Ctrl]+[Down] to mark the wole range in this column from row 2 to the last used row, and press [Enter] to paste your formula.)

In this formula, the search area increases, the further you copy this down.
So this first time a duplicate item is found, the value will be 1 (i.e. false) the second, third or more times this duplicate item is found, the value will be greater than 1 and give a value of true.