Using COuntif


Posted by brian on January 19, 2000 9:55 AM

I am using the countif formula to separate data into two sets.
Either above or below a value. In addition, the range is a
variable, thus the use of "y" in my equation. Does
anyone see why the following will not work?


ActiveCell.Formula = "=Countif(R[" & -(y) & "]C:R[-3]C, "<.5")"

Yet, the range syntax
works fine for other formulas (Average, Max, Min). It
appears to be something with the "Countif" formula itself.

Posted by kaiowas on January 20, 2000 6:09 AM

The countif function requires the criteria to be enclosed in quotes which it appears you have attemped but because you are working with strings in VBA you must use in order to include a quote as part of the string you must use a double quote. The formula below should work:

ActiveCell.Formula = "=Countif(R[" & -(y) & "]C:R[-3]C, ""<.5"")"

Posted by kaiowas on January 20, 2000 6:12 AM

Oops, It appears I can manage excel problems but typing coherent English is a different matter. That last sentence should have read as follows.


....but because you are working with strings in VBA in order to include a quote as part of the string you must type a double quote. The formula below .....

Sorry



Posted by brian on January 21, 2000 11:44 AM


THanks a bunch, I 'll give it a go!!