On Mon, 3 Jul 2006 06:48:44 -0500, abc99 wrote:
Hi, i have a problem if i need to count the number of occurrences of odd
or even numbers in an array how should i go about writing it. COUNTIF
and COUNT does not seem to work. Haveing some difficulties in writing
the formula.
I.e from B3:H11 i need to count the number of times odd and even
numbers occurs; how should i write the formula or what formula should i
use. Please advice. Thank you. ^^
Create separate range of cells, with ones for odd and zeros for even, then
use COUNTIF formula.
Or, write a VBA function, name it CountOdd and use it in a formula.
Public Function CountOdd(r as Excel Range) As Long
dim retval as long
For Each c in r.Cells
if c.value mod 2 = 1 then retval = retval+1
Nect c
CountOdd=retval
End Function
Do similar thing for even values...
--
PL