如何根据要填充的 header 列中输入的内容使查询列动态化?

How can I make queried column dynamic, as per what's entered in the column header to be populated?

现在,我可以用查询的数据填充 sheet 并动态获取目标列 header 名称,使用此:

=query(
Scenarios!A5:FQ,
"select "&REGEXEXTRACT(ADDRESS(5,MATCH(B2,Scenarios!A5:5,0)),"[A-Z]+")&"
 where "&REGEXEXTRACT(ADDRESS(5,MATCH("PO #",Scenarios!A5:5,0)),"[A-Z]+")&" = 
 '"&$B&"'",0)

在这种情况下如何使用类似的方法?

=vlookup(AB9,Scenarios!A:BL,64,FALSE)

Here is an example of the data

谢谢!

参见:

=FILTER(A7:C; REGEXMATCH(A7:C7; "Region|Rep"))

如果列的顺序很重要:

=QUERY(FILTER(A7:C; REGEXMATCH(A7:C7; "Region|Rep")); "select Col2,Col1")

或者你可以试试:

=INDEX(VLOOKUP(ROW(A7:A); {ROW(A7:A)\ B7:C}; {3\ 2}; 0))

或喜欢:

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