selected data for avg matching buttons.xlsm

This file may help with your question. Look at the functions that I use to populate the data. I use the functions: ifError, index and match.

=IFERROR(INDEX($A$5:$A$504,MATCH($F4&I$3&$G4,$B$5:$B$504&$C$5:$C$504&$D$5:$D$504,0)),"")
For each line click (shift + control + enter). This button utilizes this function in my code. This button also formats the excel spreadsheet with the use of a recorded macro. If you have more questions let me know.

Thanks