countifs NOT empty cells

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
2,005
Office Version
  1. 365
Platform
  1. Windows
I am a little confused. Column G in my spreadsheet results from a formula that compares dates. if there is no date in the other column, the formula result is " " or empty.

If i code an autofilter criteria in VBA to select all non blank cells in a column within a table the syntax is:

.ListObjects("CalcPPR").Range.AutoFilter Field:=7, Criteria1:="<>"

The result is 172 rows of data.

BUT when i want to use a formula to count the non blank cells in a range using the same criteria:

=COUNTIFS(G6:G2216,"<>")

the result is the count of all cells in the range (2,210).


And using:
=COUNTIFS(G6:G2216,"< >") ==> there is a single space between < and >,

the result is a count of all cells with nothing in them (except the formula) (2,038).

AND using:
=COUNTIFS(G6:G2216,"<>""")

the result is, again, the count of all cells in the range (2,210)
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
=COUNTIFS(G6:G2216,"<>") will count all the cells in range G6:G2216 that have constants or formulas in them, regardless of whether the formulas return "" or not.

If you want to count all cells that are truly blank or have a formula in them that's returning "", try =COUNTIFS(G6:G2216,"")
 
Upvote 0
=COUNTIFS(G6:G2216,"<>") will count all the cells in range G6:G2216 that have constants or formulas in them, regardless of whether the formulas return "" or not.

If you want to count all cells that are truly blank or have a formula in them that's returning "", try =COUNTIFS(G6:G2216,"")
I actually want to count all cells in the range that have a value. so in your first sentence, you state
=COUNTIFS(G6:G2216,"<>") will count all the cells in range G6:G2216 that have constants or formulas in them

I want only to count the number of constants that are returned. In this case the answer is 172, which is the number of rows that remain after applying the autofilter as described above.
 
Upvote 0
I actually want to count all cells in the range that have a value. so in your first sentence, you state


I want only to count the number of constants that are returned. In this case the answer is 172, which is the number of rows that remain after applying the autofilter as described above.
Do all the cells in your range contain formulas?
 
Upvote 0
COUNTIFS and SUMPRODUCT count the null string returned by a formula differently.

Code:
=SUMPRODUCT(--(G6:G2216<>""))

is likely what you're looking for
 
Upvote 0
Solution
COUNTIFS and SUMPRODUCT count the null string returned by a formula differently.

Code:
=SUMPRODUCT(--(G6:G2216<>""))

is likely what you're looking for
This did the job nicely. thanks oaktree.
 
Upvote 0
Just for completeness. In MS365 you don't even need the SUMPRODUCT just SUM will do.
Excel Formula:
=SUM(--(G6:G2216<>""))
 
  • Like
Reactions: ajm
Upvote 0

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top