Home > OS >  How can I make queried column dynamic, as per what's entered in the column header to be populat
How can I make queried column dynamic, as per what's entered in the column header to be populat

Time:04-21

Right now, I can populate a sheet with data queried and that gets the destination column header name dynamically, using this:

=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$13&"'",0)

How can I use a similar approach when in this case?

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

enter image description here

if order of columns matters:

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

enter image description here

or you can try:

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

enter image description here

or like:

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

enter image description here

  • Related