Thread: COUNTIF
View Single Post
  #7   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi Laura
but why not use the formulas as I provided it to you.
Your formula
=COUNTIF(B1:B12,"=0")-COUNTIF(B1:B12,"<=99")
of course won't work.
Use:
=COUNTIF(B1:B12,"=0")-COUNTIF(B1:B12,"99")

To explain it:
The first part: COUNTIF(B1:B12,"=0") count ALL occurenced there B1:B12
is =0. So this includes also all cells which are larger than 99. So
the first part returns too many matches. To correct this you have to
SUBTRACT the amount of occurences which are 99. This is what the
second part COUNTIF(B1:B12,"99") does.

To give you an example
B1: 90
B2: 99
B3: 120

So your expected result should be two. Now lets evaluate what both
formula parts return:
1. =COUNTIF(B1:B3,"=0") - This of course returns 3. So it also
counts the value 120 as match.
2. =COUNTIF(B1:B3,"99") - and this returns 1 (the 120 value).

So the final result is 3-1 = 2 (and this would be the expected result).
So the above formula count the values BETWEEN these numbers. And as Peo
in his first post suggested if this logic is not that obvious for you
you may try an alternative solution:
=SUMPRODUCT(--(B1:B12=0),--(B1:B12<=99))

This will return 2 as well.

Post back if you still have questions but PLEASE try the exact
suggestions we provided to you



--
Regards
Frank Kabel
Frankfurt, Germany

"Laura Mc" schrieb im Newsbeitrag
...
Sure. I'm trying to count the cells BETWEEN two numbers (i.e., 0-99)

and
you've shown it as 0 and 99 and it should be 0 and <99. I just

copied &
pasted the formula that EXCEL Help suggested to be sure I did not

type it
incorrectly. Here it is again:

=COUNTIF(B1:B12,"=0")-COUNTIF(B1:B12,"<=99")

"Frank Kabel" wrote:

Hi Laura
could you post for your two first examples the EXACT formulas you

have
used as I got the following results
0-99: 1 for the formula:

=COUNTIF(A1:A3,"=0")-COUNTIF(A1:A3,"99")
100-199: 1 for the formula:
=COUNTIF(A1:A3,"=100")-COUNTIF(A1:A3,"199")

So either something is different in your formulas or both Peo and I

are
missing something in your explanation :-)

--
Regards
Frank Kabel
Frankfurt, Germany

"Laura Mc" schrieb im

Newsbeitrag
...
This is my first time to use this discussion group and I'm

shocked to
see a
response written such as yours was. I suppose my expectations

could
have
been too high. Of course I tested it first. I tried and

received
the
following results. I believe I would benefit most if you could

just
explain
where I went wrong in more detail and with