Hi

=IFERROR(IF($A14="","",AVERAGE(OFFSET($AN14,0,AK2-AK1,1,AK$1))),0)

where AK2 is the linked cell from your drop down (form control)

if it's activex, get the date column index using

=match(ak2,an3:bg3)

and replace the highlighted range in the formula with this formula cell.