Finding common data in multiple columns and rows in Excel

S

sparham

I'm trying to determine the number of times that certain data appears in two
columns, on the same row. For example:
Below are two columns. I want to know how many times that column G has
"apple" and column K has "pie". I'm only interested in knowing how many rows
contain both "apple" and "pie".
Column G Column K
apple pie
apple cider
orange juice
banana pudding
apple pie
banana bread
kiwi pie
apple pie
orange juice
kiwi juice
kiwi pie
orange danish
apple cider
orange juice
apple pie
orange juice
kiwi juice

Using the correct function(s), I should be able to get the answer; 4. But I
don't know what function(s) to use.
 
P

Peo Sjoblom

=SUMPRODUCT(--(G2:G100="apple"),--(K2:K100="pie"))

--
Regards,

Peo Sjoblom

(No private emails please, for everyone's
benefit keep the discussion in the newsgroup/forum)
 
M

Max

One way

Assume source data is in Sheet1, cols G and K, rows 2 to 20

In Sheet2
-------------

Assuming you have in A2: apple, in B2: pie, with other similar paired inputs
in A3:B3, A4:B4, etc

Put in C2:

=SUMPRODUCT((TRIM(Sheet1!$G$2:$G$20)=TRIM(A2))*(TRIM(Sheet1!$K$2:$K$20)=TRIM
(B2)))

Copy C2 down

Adapt the ranges to suit, but note that you can't use entire col refs (A:A,
B:B, etc) within SUMPRODUCT
 
S

sparham

Thank you, Peo Sjoblom! That was what I needed to know in order to get the
totals that I needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top