Countif but with criteria ("Y")

ellison

Active Member
Joined
Aug 1, 2012
Messages
343
Office Version
  1. 365
Platform
  1. Windows
Hi, we use a really helpful couple of counts to show us the "nth" occurrence and the overall count of number of occurrences of a string.
Cell C2:
VBA Code:
=COUNTIF(B$2:B2,B2)

Cell D2:
VBA Code:
=COUNTIF(B:B,B2)

We are wondering if something similar could be done... BUT also take into account whether or not to use the string in the counts

i.e. checking that the criteria on that row is a "y" before including it in the counts

For example below: "Charlie" appears on 3 rows. But only 2 of those 2 rows have "y" as the criteria. So is there maybe a way to calculate the countifs to reflect that?


RowHeader-1nth [no criteria]nth overall [no criteria]Criterianth [where criteria is "Y"]overall [where criteria is "Y"]
2alpha11y11
3beta13y12
4beta23
5beta33y22
6charlie13
7charlie23n
8charlie33y11
900
10delta11y11


Thanks for taking a peek...
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Use COUNTIFS:

=COUNTIFS(B$2:B2,B2,E$2:E2,"Y")
 
Upvote 0
In future please use the mini-sheet option as it includes any formulae & also shows us which columns/rows are being used.

Try
Excel Formula:
=IF(E2="y",COUNTIFS(B$2:B2,B2,E$2:E2,"y"),"")
 
Upvote 0
Solution
Huge thanks for your help, that works beautifully!

And apologies - I will use the mini-sheet option in future, sorry
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,153
Messages
6,123,325
Members
449,097
Latest member
gameover8

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