The following will average all values in Col B that are equal to the top two
largest values in Col A. that could be anywhere from 2 values in Col A to
all the values in Col A.
=AVERAGE(IF($A$1:$A$100=LARGE($A$1:$A$100,{1,2}),$ B$1:$B$100))
array entered using CTRL+SHIFT+ENTER
This will NOT just pick the first two values that happen to be equal to the
top two and just use those (unless there are only two), eg
A B
2 3
4 4
6 2
3 7
6 3
5 8
6, 6, and 5 are equal to the top two largest, so it will average 2,7,3 and
give 4
--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03
----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------
"Joseph Spain" wrote in message
news:w7zLd.108034$Wo.58646@lakeread08...
"Jason Morin" wrote:
Ken is asking what should the formula do if 3 or more
numbers tie for the highest number. For example, if A1:A3
= 9 and A4 = 2, do you want to average B1 and B2, or B1
and B3, or B2 and B3? Or all 3?
What if there is a tie for the 2nd highest? For example,
if A1 = 9, A2 = 7, A3 = 2, A4 = 7, do you average B1 and
B2, or B1 and B4? Or all 3?
In a tie case, whichever two values that Excel idetifies as the largest
will be acceptable, but seeing the solution for all values in the case of
a tie would also be useful.
Thanks for all the work you guys do. You answer about 99% of my Excel
questions without ever knowing it. I rarely have to post to find answers,
but I couldn't find a solution for this one. Thanks again to all of you
who post here daily.
Best Regards,
Joseph
|