How to write this function?

Z

Zilla

Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!
 
Z

Zilla

Thanks but this will be tedious since you hard-coded "2",
which is just an example value. So if I change "2" to "19",
I'd have to change it in ALL the formulas...
 
M

Max

You could point Topper's array suggestion to the source cells in col A
Eg in C1, array-entered (press CTRL+SHIFT+ENTER):
=AVERAGE(IF($A$1:$A$100=A1,$B$1:$B$100))
Copy down (Adapt the ranges to suit before you copy down)

---
 

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