COUNTIF

  • Thread starter Thread starter mpajenn
  • Start date Start date
M

mpajenn

In one column I have "M" or "W" and in the next column I have # representing
shoe sizes. To get a shoe count I put in the formula
=countif(d4:d145,m)+countif(e4:e145,#), (the # sign represents the shoe size
I am trying to count). The formula works good except if a shoe size falls
into both the m and w category it shows up in both counts instead of just the
one. I have tried putting "" marks around the M or W but it does not help.
Anyone have any ideas?

Jenn
 
=SUMPRODUCT(--(D4:D145="M"),--(E4:E145=#))
and for the ladies
=SUMPRODUCT(--(D4:D145="W"),--(E4:E145=#))

That should help some. To explain, the tests of D4:D145 work row by row and
each one is evaluated either true (1) or false(0). The results for that row
are multiplied by one another and that result is kept in a running total.
For any given row you have possible results:
0 * 1 = 0
1 * 0 = 0
0 * 0 = 0
1 * 1 = 1
so only when both conditions are met do you get a non-zero value to keep a
running total of.

Try it, you'll like it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top