View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Finding the avg of several of cells meeting a criterion (index, ma

hi
try using the sumif and countif togeather ie..

=SUMIF(B2:B490,"sell",A2:A490)/COUNTIF(B2:B490,"sell")

regards
FSt1

"Babymech" wrote:

I have a range of numeric values in A2:A490, and a range of text values in
B2:B490. In C2, I want to have the AVERAGE of all values in A2:A490 that
match against a specific string in B2:B490.

For example ( I hope this formating will work...):

A B C D
1 23 Buy 23.33 21
2 21 Sell
3 21 Sell
4 22 Buy
5 23 Buy

So in C1, I want to have a formula that averages all values in A for which
the corresponding cell on the same row in B contains the word "Buy". In D1 I
want to have the average of all "Sell" numbers. Any suggestions (preferrably
without going into VBA)?

PS. As an extra bonus question, is it possible to set this up so that the
criterion checked for in C1 is whether or not LEFT(B1:B5;1)="Y"? Thanks