A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
So, if I understand you correctly, if W18 and W22 contain "Y", and W19:W21 contain "N" you want the formula on row 18 to deliver 'UPC Code file.txt'!A16 and you want the formula on row 19 to deliver 'UPC Code file.txt'!A17 ?
The ideas I have thought of will probably only work if the .txt file is open. Is that OK?
I will suppose that the first row containing the formulas is row 2 and that the first UPC Code is in row 2 of the txt file.
The formula on row 2 would be
=IF(W2="Y",OFFSET('UPC Code file.txt'!$A$1,COUNTIF(W$2:W2,"Y"),0),"")
That formula can then be copied down