in cell G2:
=IF(AND((MATCH(G$2,$C$3:$C$14,0)-$F3)>=0,(MATCH(G$2,$C$3:$C$14,0)-$F3)<8),$D3,0)
copied down and across.
If you want the specified number to be variable, put that number in say cell F2 and change the formula to:
=IF(AND((MATCH(G$2,$C$3:$C$14,0)-$F3)>=0,(MATCH(G$2,$C$3:$C$14,0)-$F3)<$F$2),$D3,0)