Hi and welcome to the forum

I would suggest you update your profile - it says 2003, but your uploaded file is 2007 or later.

Try this, copied from the bottom up...

=AVERAGEIFS($B$1:$B$2111,$A$1:$A$2111,"<="&A2111,$A$1:$A$2111,">="&A2111-DATE($H$1,0,0))