Search code examples
arraysgoogle-sheetsjoinselect

QUERY Select cells equals to an array from another tab


I want to import in a google sheet , the data of URLTab, only where Col 1 is equal to the column A of Tab2.

When I use the following formula, refering to only the first row of Tab2, it works fine.

=QUERY(Importrange("URL";"URLTab!A3:P");"select * where Col1 =  '"&Tab2!A2& "'")

When I try to refer to the whole column A, it gives an error :

=QUERY(Importrange(""URL";"URLTab!A3:P");"select * where Col1 is not null and Col1 matches'"&JOIN("|",  '"&Tab2!A2:A6& "'")"))

Could you please help me on the 2d formula ?

Thank you


Solution

  • You have some extraneous single and double quotes within the JOIN. At a guess, try this:

    =QUERY(Importrange("URL";"URLTab!A3:P");"select * where Col1 is not null and Col1 matches '"&JOIN("|";Tab2!A2:A6)&"'")