I put this formula in L2 copied down to L507 (hide if required or move somewhere else)

=COUNTIF(A:A,M2)

and then this formula in N2 copied across and down to AB507

=LOOKUP(N$1,INDEX($F$2:$F$

That could be shortened using OFFSET but the formula would probably be less efficient

Note: I formatted columns F and G as dates - that isn't strictly necessary but it won't affect the formula

see attached

regards, barry

27328856.xlsx