countifs with variable criteria

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
679
Office Version
  1. 2016
Platform
  1. Windows
Hi,
Is there a formula that I could put into cell K11 that will count the number of occurrences based on the variable criteria entered into the table J8:K9?
Am looking for a formula solution in this instance please.
Many thanks,
2dtrurt.jpg
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try

=COUNTIFS(INDEX(B4:H25,0,MATCH(J8,B3:I3,0)),K8,INDEX(B4:H25,0,MATCH(J9,B3:I3,0)),K9)

M.
 
Upvote 0
Have just thought of something.
Is there a way that this formula can be adapted so if one of the two blocks of criteria is empty (ie. J8:K8 or J9:K9 contain nothing) then the formula will calculate using just the criteria that is available?
I know how to use a long string of nested IF statements IF(J8="", etc.. but was wondering if there was a simpler way (without vba). That way I could adapt it further with more criteria blocks without huge formulas.
Any help would be much appreciated.
Thanks
 
Upvote 0
Maybe...

=COUNTIFS(INDEX(B4:H25,0,MATCH(J8,B3:H3,0)),IF(K8<>"",K8,"<>"),INDEX(B4:H25,0,MATCH(J9,B3:H3,0)),IF(K9<>"",K9,"<>"))

M.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,186
Members
449,071
Latest member
cdnMech

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