Hello,
I need some help using the vlookup and match (maybe also the index function) with this excel problem I'm having. I also tried using a couter in my VBA code, but the counter stuff got really messy.

Thank you in advance! Send me a direct message if you want to see the excel file. Sorry about the formatting.


=VLOOKUP($AH7,AH6:AH504,MATCH(AK$4,$AK4:$AK21,0),FALSE)& VLOOKUP(AI6,AI$6:AI$504,MATCH(AN3,AN3,0),FALSE)&VLOOKUP(AJ7,AJ$6:AJ$504, MATCH(AN3,AN3,0),FALSE)


Avg X Y Z
172 54 02 1
74 54 02 3
168 54 03 1
78 54 03 3


Therefore I want to find the value 74 (avg) and put it in this position, and so forth from the x, y, z coordinates to give the avg. My spreadsheet has 504 rows and 49 columns. I want to either use vlookup and match functions, or I need help writing some VBA code.

blank blank 1 2 3
54 3 blank 74 78
54 2 blank blank blank
54 1 blank blank 168