If you have selected C2:H3 and G4:H5 or you have selected C2:F3 and G2:H5 and you have formed a named range with the name ATestRange, then the COUNTIF function cannot work, since this function has in its syntax: range and criteria.
If the named range is not given as a rectangular shape, then the COUNTIF function does not consider the range as a single one, but as multiple ranges and for this reason it cannot work to make the desired calculation.
In such a case you can use this formula in cell K2:
=SUM(--(TOCOL(ATestRange, 1) = J2))
HTH