Using COUNTIFS alongside HLOOKUP

deacon10

Board Regular
Joined
Aug 9, 2010
Messages
59
Office Version
  1. 365
Hi all,

I am hoping one of you great people can help with a simple problem (I think) that I can’t get my head around.

I am trying to use a COUNTIFS statement alongside a HLOOKUP.

In Sheet 1 in columns C to F, I want to count the ‘Modules’ (Test1 to Test8) in Sheet 2 that = 1. The First condition is if Sheet1 column A is 1 in Sheet2 column J, and the third is if Sheet1 C3 is 1 in Sheet2 column N.
The items in red below probably best show the conditions:-

1685095509432.png


1685095449945.png


I have this formula that works, (an example in Sheet1 C4)

Excel Formula:
=COUNTIFS(Sheet2!J:J,1,Sheet2!I:I,"Slice1",Sheet2!N:N,1)

Unfortunately, the above formula is quite manual for setting up columns J & N – particularly if a new Module is added. Ideally, I would like some type of HLOOKUP for conditions 1 & 3 to do the count

Any ideas greatly appreciated
 

Attachments

  • 1685095416128.png
    1685095416128.png
    11.3 KB · Views: 13

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You will have a better chance of getting a reponse if you provide some sample data using XL2BB.
It saves anyone wanting to respond from having to manually recreate the data.

See if this works for you:
20230526 Multi Dimension Match deacon10.xlsx
ABCDEF
1
2
3ModuleSliceTest5Test6Test7Test8
4test1Slice12122
5test2Slice10000
6test3Slice20000
7test4Slice30001
Sheet1
Cell Formulas
RangeFormula
C4:F7C4=COUNTIFS( INDEX(Sheet2!$H$3:$Q$20000,0,MATCH($A4,Sheet2!$H$3:$Q$3,0)),1, Sheet2!$I$3:$I$20000,$B4, INDEX(Sheet2!$H$3:$Q$20000,0,MATCH(C$3,Sheet2!$H$3:$Q$3,0)),1)



Sheet2 - for anyone else who might want to answer

20230526 Multi Dimension Match deacon10.xlsx
HIJKLMNOPQ
2
3AccSliceTest1Test2Test3Test4Test5Test6Test7Test8
41234Slice111111
51535Slice11111
64563Slice31
71538Slice311
8
Sheet2
 
Upvote 1
Try:
Libro1
ABCDEF
1
2
3ModuleSliceTest5Test6Test7Test8
4test1Slice12122
5test2Slice10000
6test3Slice20000
7test4Slice30001
Sheet1
Cell Formulas
RangeFormula
C4:F7C4=COUNTIFS(Sheet2!$I:$I,$B4,INDEX(Sheet2!$J:$Q,0,MATCH($A4,Sheet2!$J$1:$Q$1,0)),1,INDEX(Sheet2!$J:$Q,0,MATCH(C$3,Sheet2!$J$1:$Q$1,0)),1)


It's a pity that the row numbers are not visible in your images.

I'm considering row 1 for the headers on sheet2:
Libro1
IJKLMNOPQ
1SliceTest1Test2Test3Test4Test5Test6Test7Test8
2Slice111111
3Slice11111
4Slice31
5Slice311
Sheet2


If the headers are on another row, then change the number 1 in this part of the formula:
=COUNTIFS(Sheet2!$I:$I,$B4,INDEX(Sheet2!$J:$Q,0,MATCH($A4,Sheet2!$J$1:$Q$1,0)),1,INDEX(Sheet2!$J:$Q,0,MATCH(C$3,Sheet2!$J$1:$Q$1,0)),1)
--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 
Upvote 1
Solution
Try:
Libro1
ABCDEF
1
2
3ModuleSliceTest5Test6Test7Test8
4test1Slice12122
5test2Slice10000
6test3Slice20000
7test4Slice30001
Sheet1
Cell Formulas
RangeFormula
C4:F7C4=COUNTIFS(Sheet2!$I:$I,$B4,INDEX(Sheet2!$J:$Q,0,MATCH($A4,Sheet2!$J$1:$Q$1,0)),1,INDEX(Sheet2!$J:$Q,0,MATCH(C$3,Sheet2!$J$1:$Q$1,0)),1)


It's a pity that the row numbers are not visible in your images.

I'm considering row 1 for the headers on sheet2:
Libro1
IJKLMNOPQ
1SliceTest1Test2Test3Test4Test5Test6Test7Test8
2Slice111111
3Slice11111
4Slice31
5Slice311
Sheet2


If the headers are on another row, then change the number 1 in this part of the formula:
=COUNTIFS(Sheet2!$I:$I,$B4,INDEX(Sheet2!$J:$Q,0,MATCH($A4,Sheet2!$J$1:$Q$1,0)),1,INDEX(Sheet2!$J:$Q,0,MATCH(C$3,Sheet2!$J$1:$Q$1,0)),1)
--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
Amazing stuff Alex & Dante, I really appreciate your advice and help. This works great.

Thanks you both!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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