Needs to be "array entered" but for averages why not use AVERAGE?

=AVERAGE(IF($A$9:$A$39>=$B$1,IF(A$9:$A$39<=$C$1,IF($B$9:$B$39<>"",$B$9:$B$39))))