Cell formula HELP

Hello I'm using Microsoft Excel for Mac 2011 and I'm trying to come up with a formula that does the following:

I want to take the average of all cells in column B such that their respective cells in the A column are the same as those in cell (iA) exluding the the entry in B that corresponds to the cell (iB)

So to explain myself here is an example For the number ID 99666 I want to the formula to then average those that in A have 99666 but exclude from the average the B cell in that same row . so....
.........A.........B..........what I want
1. ..99666 ..43.24 ...avg( 51.19 and 53.42)
2. ..99666 ..51.19 ...avg (43.24 and 53.42)
3... 99666 ..53.42 ...avg (43.24 and 51.19)
4. ..99577 ..58.79 ...avg (54.59, 67.35, 70.64, 63.13)
5... 99577 ..54.59 ...avg( 58.79, 67.35, 70.64, 63.13)
6. ..99577..67.35 ...avg (58.79, 54.59, 70.64, 63.13)
7... 99577 ..70.64
8... 99577..63.13

Almir's picture

AverageIf with relative references

Suppose your example data is from cell A1 to C8, copy this formula to D1 and copy it down:
=AVERAGEIFS($C$1:$C$8;$A$1:$A$8;"<>"&A1;$B$1:$B$8;B1)