=IF(D14='geo capacity'!A1,VLOOKUP(D15,'geo capacity'!A1

1050,2,IF(D14='geo capacity'!K1,VLOOKUP(D15,'geo capacity'!K2:O1050,2,IF(D14='geo capacity'!F1,VLOOKUP('geo capacity'!F2:H1050,2,FALSE))))))
What I am trying to do is look up piles in a table depending on the geotechnical capacity of the soil. The above formula only returns a product if the code in D14 is the first look up in the table. If not it returns false. What I want to do is insert the soil code and then be able to look up the piles with the corresponding soil code in the table.
The table consists of 3 soil types in each of cells A1, F1 and K1 with the appropriate piles listed under each soil type.