COUNTIF and VLOOKUP combination?

chuckles1066

Banned
Joined
Dec 20, 2004
Messages
372
Apologies if this one's been covered, I couldn't find it.

Sheet1, cell A2 contains a person's name

Sheet2, column A will also contain that person's name (somewhere). I need to be able to count which columns from B-G contain a value greater than 0. So it seems (to me) to be a combination of COUNTIF and VLOOKUP except I can't get the syntax right.

I've messed about with SUMPRODUCT to no avail, I think I might even have dabbled with INDEX, MATCH and OFFSET as well! So I HAVE tried before asking :-)

Thanks in advance.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
This should work for you:

=COUNTIF(OFFSET(Sheet2!$B$1:$G$1,MATCH(B2,Sheet2!$A:$A,0)-1,0),">"&0)
 
Upvote 0
Brilliant, thank you very much.

I got a circular reference error and then I changed the B2 after the MATCH statement to A2 and it works a treat!
 
Upvote 0
Apologies if this one's been covered, I couldn't find it.

Sheet1, cell A2 contains a person's name

Sheet2, column A will also contain that person's name (somewhere). I need to be able to count which columns from B-G contain a value greater than 0. So it seems (to me) to be a combination of COUNTIF and VLOOKUP except I can't get the syntax right.

I've messed about with SUMPRODUCT to no avail, I think I might even have dabbled with INDEX, MATCH and OFFSET as well! So I HAVE tried before asking :-)

Thanks in advance.
Try this...

Assuming you enter the formula in Sheet1 cell B2.

=COUNTIF(INDEX(Sheet2!B2:G15,MATCH(A2,Sheet2!A2:A15,0),0),">0")
 
Upvote 0
Apologies if this one's been covered, I couldn't find it.

Sheet1, cell A2 contains a person's name

Sheet2, column A will also contain that person's name (somewhere). I need to be able to count which columns from B-G contain a value greater than 0. So it seems (to me) to be a combination of COUNTIF and VLOOKUP except I can't get the syntax right.

I've messed about with SUMPRODUCT to no avail, I think I might even have dabbled with INDEX, MATCH and OFFSET as well! So I HAVE tried before asking :-)

Thanks in advance.
Looks like...

B2, Sheet1, control+shift+enter, not just enter...

Either:

=SUM(IF(Sheet2!$A$2:$A$100=A2,(Sheet2!$B$2:$G$100>0)+0))

Or:

=SUM(IF(Sheet2!$A$2:$A$100=A2,IF(ISNUMBER(Sheet2!$B$2:$G$100),(Sheet2!$B$2:$G$100>0)+0)))

The latter can cope with text values that might occur in B:G.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,310
Members
452,906
Latest member
phanmemchatdakenhupviral

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