如何在表格中使用 INDEX+VLOOKUP 动态获取条件列?

How to get criteria column dynamically using INDEX+VLOOKUP in Sheets?

一个善良的人帮助我达到了这一点,但我还有一个问题要解决:

如何根据ID列填充RepRegion,但是这个列可能会移动,所以获取它必须是动态的,就像获取 RepRegion 列一样。

这是工作公式,没有条件:

=INDEX(VLOOKUP(ROW('From Sheet1'!A7:A); {ROW('From Sheet1'!A7:A)\ 'From Sheet1'!B7:C}; MATCH({"Rep"\ "Region"}; 'From Sheet1'!A7:C7; 0); 0))

Here's 样本数据。

一如既往地感谢您的帮助!

这个太棒了

=ARRAYFORMULA(VLOOKUP(A7:A,{INDIRECT("'From Sheet1'!"&LEFT(ADDRESS(7,MATCH("ID",'From Sheet1'!7:7,0),4))&"7:"&LEFT(ADDRESS(7,MATCH("ID",'From Sheet1'!7:7,0),4))),INDIRECT("'From Sheet1'!"&LEFT(ADDRESS(7,MATCH("Rep",'From Sheet1'!7:7,0),4))&"7:"&LEFT(ADDRESS(7,MATCH("Rep",'From Sheet1'!7:7,0),4))),INDIRECT("'From Sheet1'!"&LEFT(ADDRESS(7,MATCH("Region",'From Sheet1'!7:7,0),4))&"7:"&LEFT(ADDRESS(7,MATCH("Region",'From Sheet1'!7:7,0),4)))},{2,3}))

代替单元格 B7 中的公式,这还假设您的 headers 在工作表 1 的第 7 行。

尝试:

=INDEX(IFNA(VLOOKUP(A7:A, 
 {FILTER('From Sheet1'!A7:Z, 'From Sheet1'!7:7="ID"), 'From Sheet1'!B7:C}, 
 MATCH({"Rep", "Region"}, 'From Sheet1'!A7:C7), 0)))