1

I want to compare the data in column A and B in excel. For every cell in B that matches any cell in A I want to take the corresponding value in C and add this up. Then I want to get the average of these cells in C.

Example: 
A       B       C      D
jan     jan     8      apple
piet    kees    7      apple
bas     erik    9      pear
jan     piet    2      kiwi
tom                    kiwi
lies                   apple
jan                    pear
sam                    lemon
kees                   pear

In the example above I would want the outcome to be 5.66666 if you consider column A, B and C. The numbers in column C that correstpond with 'jan', 'kees', and 'piet' in column B are averaged, because the names in column B also are listed in column A.

Additionally I would want to also add in column D. How can I also add that I only want the people in A that have 'apple' listed in column D. So the outcome in the example above would be 7.5

3
  • Would you mind refining your explanation please? I can't understand the requirement Commented May 12, 2018 at 22:24
  • 17 ÷ 3 ≠ 8.5 in my maths Commented May 12, 2018 at 22:25
  • Yes indeed! I changed t in the txt above Commented May 13, 2018 at 11:10

2 Answers 2

1

Put this array formula somewhere and finalize it with ctrl+shift+enter rather than just enter.

=AVERAGE(IF(COUNTIF(A1:A9, B1:B4), C1:C4))

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Jeeped! This worked like a charm. I'm trying to add another criterium, but not very succesful ;) I might get back to you later for some more help :)
Maybe you know the answer: If I list fruit in column D, which show the fruit that the people in column A have eten, how can I then only average the numbers in column C for which the names not only match, but who have only eaten lets say an apple. - I added this example above, hopefully to clarity my question.
0

a simple google search revealed the function COUNTIF(range,condition) that returns 1 if your B is somewhere in A.

I would go with =IF(COUNTIF(A_start:A_end,B_i),C_i,0) and sum the range in C

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.