View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove Harlan Grove is offline
external usenet poster
 
Posts: 733
Default Handling #NUM! error

"Michel Khennafi" wrote...
....
I have 4 zero values in C662:F662 and the formula I created in G662 is
=SMALL(C662:F662,COUNTIF(C662:F662,0)+1)

How could I modify the formula to avoid the #NUM! error display...


If the formula above returns #NUM! because there are only 4 cells in
this range, they're all zero, so the COUNTIF call returns 4, so the
2nd argument to SMALL is 5, and 5 exceeds the number of cells in
C662:F662. If you want the smallest positive number in that range or
"" if there aren't any, try

=IF(COUNTIF(C662:F662,"0"),SMALL(C662:F662,COUNTI F(C662:F662,"<=0")
+1),
"")