I think averageifs can accomplish that though I haven't used that function yet but if you have 2007 or later excel it is available. Give it a try and see.