Sort of Count if but using and array across ROWs.

matt_ward

New Member
Joined
Jul 6, 2015
Messages
19
So... bit stumped on this but here goes.

Say I have a list of unique values that are fruit in a vertical list

Appleresult
Pear3applepeartreeDogLemon
Orange
Grapes
Lemon

I want to be able to count how many times things in the vertical list are seen in the Horizontal list. so in the above the answer is 3 as Apple, pear & lemon are in the list.

this possible?? thinking it involves some sort of Index and count?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi,

2 ways, 1st is an array formula, 2nd is regular:

Book3.xlsx
ABCDEFGH
1Appleresult
2Pear3applepeartreeDogLemon
3Orange3
4Grapes
5Lemon
Sheet935
Cell Formulas
RangeFormula
C2C2=SUM(COUNTIF(A1:A5,D2:H2))
C3C3=SUMPRODUCT(COUNTIF(A1:A5,D2:H2))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Solution
The SUMPRODUCT!!!! Dang! Thank you very much! Liked the first one but im going to need to do this over a large table so Sumproduct it is! Thanks again!
 
Upvote 0
Hi,

2 ways, 1st is an array formula, 2nd is regular:

Book3.xlsx
ABCDEFGH
1Appleresult
2Pear3applepeartreeDogLemon
3Orange3
4Grapes
5Lemon
Sheet935
Cell Formulas
RangeFormula
C2C2=SUM(COUNTIF(A1:A5,D2:H2))
C3C3=SUMPRODUCT(COUNTIF(A1:A5,D2:H2))
Press CTRL+SHIFT+ENTER to enter array formulas.
Do you think there is a simpler way of doing this that is less punishing for excel? I have 85,000 rows and a list of 18,000 values... Thinking this probebly DB time.
 
Upvote 0
for example...


AppleAppledoglemoncatpeachSantapear
pearApplecat
lemonSantapeachpear
peachPeardogpeachpear

The formular would be instead of having a formula that i copy down the range... if it adapted to the number of items that needed calculating that would speed things up... So some how get the results of a COUNTA(D1:J1) where the answer (7) becomes part of the CountIF array. Would ADDRESS do that?
 
Upvote 0
Hi,

I'm glad the formulas provided did answer your OP.
I can't think of a way that's "less resource intensive" for excel since your data involves 2 arrays...
And I'm not understanding your latest sample in post #5, are you thinking of restructuring your data set to make calculations more efficient?
Please elaborate, thank you.
 
Upvote 0
So in my actual spreadsheet I have 23 Columns over 80,000 rows. I could copy and paste the fomular down but it spends time evaluating empty Cells. All the cells that need evaluating are Aligned to the left (for want of a better term)... I've figured out i can use CountA to work out how many Cells contain data (not Blank) Im just working a way to have that built into the formula so that every calculation only calculates the cells that have data in them. I tried creating a Concatenated string and see if could use that but that doesn't work for some reason. Been looking at the Functions OFFSET and ROW and ADDRESS but can't seam to cobble it together.
 
Upvote 0
So in your answer... the H2 value is dynamic and based on the counta result... so if CountA evaluated 5 columns it would be H2 if it had evaluated it as 4 columns it would be E2.

=SUMPRODUCT(COUNTIF(A1:A5,D2:H2))
 
Upvote 0
Sort of accepted i have to subsitute both parts of the reference D2:H2 with an equation which is equilviant based ont he evaluation.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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