Counting error values like any other value
I have a list of data as shown below. I am trying to count how many occurrences of each unique value.
But some of these values represent error values, for example #N/A
. Is there a formula that can count both normal values and error values?
This one (entered as an array formula) can count a
other regular values as well:
=SUM(--IFERROR($A$2:$A$14=C2,FALSE))
But if I copy it over, obviously it doesn't work for error totals as it ignores errors with IFERROR
.
I know I can count #N/A
with this:
=SUM(--ISNA($A$2:$A$14))
but this is a completely different formula; I can't just drag it to the column.
I'm looking for a formula that can accommodate both without "modifying the source".
COUNTIF
will actually count them correctly, but I don't think I can use it as it only means part of the formula of a larger array.
source to share
Try this little UDF ():
Public Function Kount(rng As Range, what As Variant) As Long
Dim r As Range, st1 As String, st2 As String
st1 = CStr(what)
For Each r In rng
st2 = r.Text
If st1 = st2 Then
Kount = Kount + 1
End If
Next r
End Function
For example:
In this example, the C4 and C5 values are text values.
source to share