Counting From Two Ranges

PShingadia

New Member
Joined
Aug 5, 2015
Messages
47
Hi

Just wondered if anyone can help with a formula to count out items in a list based on a count in another range. So in the example below the little box says how many to count in total and from the list I wish to count out that many and it more to show as zero.

CountTotal Items to Count
Fox 1Fox5
Fox 2Rabbit2
Rabbit 1Sqirrel3
Rabbit 2
Rabbit -
Rabbit -
Fox 3
Fox 4
Rabbit -
Squirrel 1
Rabbit -
Squirrel 2
Fox 5
Squirrel 3
Squirrel -
Squirrel -
Squirrel -
Fox -
Fox -
Fox -

<colgroup><col span="5"><col><col></colgroup><tbody>
</tbody>


So box says 5 foxes and result I want is formula that marks out 5 foxes 1 to 5 and any more show as zero. Marked out 2 rabbits and rest shown as zero, etc. I have the formula = IF(AND(COUNTIF($C$3:$C3,$H$3)<=$I$3, $C3=$H$3), COUNTIF($C$3:$C3,$H$3), 0) but don't know how to apply over the range.

Thanks for your help.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Somthing like this should work ok.

=IF(COUNTIF($A$2:A2,A2)>VLOOKUP(A2,$F$2:$G$4,2,0),0,COUNTIF($A$2:A2,A2))

MAke sure you spell your words correctly or it will fail!
 
Upvote 0
A
B
C
D
E
F
G
H
1
Fox
1​
Fox
5​
2
Fox
2​
Rabbit
2​
3
Rabbit
1​
Squirrel
3​
4
Rabbit
2​
5
Rabbit-
6
Rabbit-
7
Fox
3​
8
Fox
4​
9
Rabbit-
10
Squirrel
1​
11
Rabbit-
12
Squirrel
2​
13
Fox
5​
14
Squirrel
3​
15
Squirrel-
16
Squirrel-
17
Squirrel-
18
Fox-
19
Fox-
20
Fox-

<tbody>
</tbody>

G2=
COUNTIFS($A$1:$A$20,$F1,$B$1:$B$20,"<>"&$B$5) copy down

 
Last edited:
Upvote 0
A
B
C
D
E
F
G
H
1
Fox
1​
Fox
5​
2
Fox
2​
Rabbit
2​
3
Rabbit
1​
Squirrel
3​
4
Rabbit
2​
5
Rabbit-
6
Rabbit-
7
Fox
3​
8
Fox
4​
9
Rabbit-
10
Squirrel
1​
11
Rabbit-
12
Squirrel
2​
13
Fox
5​
14
Squirrel
3​
15
Squirrel-
16
Squirrel-
17
Squirrel-
18
Fox-
19
Fox-
20
Fox-

<tbody>
</tbody>

G2=
COUNTIFS($A$1:$A$20,$F1,$B$1:$B$20,"<>"&$B$5) copy down

Thank you very much - cleaner solution!
 
Upvote 0
Cleaner solution? Did you try it? It isn't a solution to your problem.
 
Upvote 0
Steve: you are right! Looked cleaner when I first saw but it was wrong and gone back to your solution and using : =IF(COUNTIF($A$2:A2,A2)>VLOOKUP(A2,$F$2:$G$4,2,0),0,COUNTIF($A$2:A2,A2)) which works

Is it possible to make an adjustment to this so that the items it counts are selected randomly? At the moment the count starts from the first item it finds and all those at the end are zero. Could it select these randomly but total for each comes to the quantity required in the little box?

Thanks for your help so far
 
Upvote 0

Forum statistics

Threads
1,216,212
Messages
6,129,546
Members
449,515
Latest member
lukaderanged

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top