count depending on...

Mike7

Board Regular
Joined
Dec 27, 2002
Messages
93
In column M I need to do count of three cells in the range B2K7. The range B1K1 - numbers of columns, where 1 is number for column B, 2 - for column C, etc. The range O2Q2 - numbers of columns I need to count.
I would like to automate it in the following way: when I put numbers of columns in range O2Q2 then in column M matching column letters will be counted.
Also O2Q2 numbers could be in one cell separated by comma.
Thanks.
Book1.xls
ABCDEFGHIJKLMNOPQR
112345678910
21245693259
321378100
43123781
544569102
651578101
76234692
8
Sheet1
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
Try this formula in M2 copied down

=COUNT(INDEX(B2:K2,O$2),INDEX(B2:K2,P$2),INDEX(B2:K2,Q$2))
 

sgremmo

Board Regular
Joined
Sep 1, 2004
Messages
55
It will be:

SUM(IF(HLOOKUP(O$2,$B:$K,$A2+1,FALSO)<>"",1,),IF(HLOOKUP(P$2,$B:$K,$A2+1,FALSE)<>"",1,),IF(HLOOKUP(Q$2,$B:$K,$A2+1,FALSE)<>"",1,))
 

sgremmo

Board Regular
Joined
Sep 1, 2004
Messages
55
I restarted my computer and meantime is arrived barry houdini.
My compliments for the elegance of your formula.
 

Mike7

Board Regular
Joined
Dec 27, 2002
Messages
93
I could not get it working before I turned Italian "Falso" to English "False" :)
Big thanks too!
 

Forum statistics

Threads
1,136,588
Messages
5,676,675
Members
419,643
Latest member
ishanalikhan

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
Top