简体   繁体   中英

use JOIN to pull multiple IMPORTRANGES into SORT(ARRAYFORMULA({importrange1; importrange2; etc}

How can I use JOIN (and maybe VLOOKUP? FILTER?) to make a list of IMPORTRANGES, resulting in something like {IMPORTRANGE(C3,$E$1); IMPORTRANGE(C4,$E$1); IMPORTRANGE(C5,$E$1); IMPORTRANGE...} {IMPORTRANGE(C3,$E$1); IMPORTRANGE(C4,$E$1); IMPORTRANGE(C5,$E$1); IMPORTRANGE...} {IMPORTRANGE(C3,$E$1); IMPORTRANGE(C4,$E$1); IMPORTRANGE(C5,$E$1); IMPORTRANGE...} ?

Currently, in a google sheet, I have a formula that looks like this: =SORT(ARRAYFORMULA({IMPORTRANGE(C3,$E$1);IMPORTRANGE(C4,$E$1);IMPORTRANGE(C5,$E$1);IMPORTRANGE..." where spreadsheet urls are in Col C and a range (same for every imported sheet) is in E1.

Typing it all in was fine when I only had about a dozen spreadsheets I was importing and they all already existed. But now I want to import many more spreadsheets (I heard that the limit of 50 importranges no longer applies) and they don't all exist yet. If I keep things as they are, every time I add another spreadsheet url to Column C, I'll also have to go in and edit my =SORT formula.

Then I found this thread, Fill ArrayFormula with dynamic ImportRange , which has a suggested answer listed as: ="=sort(ARRAYFORMULA({"&JOIN(";",ArrayFormula("IMPORTRANGE("""&VLOOKUP(FILTER(G2:G20,G2:G20<>""),Sheet3!$A$2:$B,2,0)&""","""&G1&"!A2:B"")"))&"}),1,True,2,True)" The JOIN in there looks intriguing (I just recently learned about JOIN) but I don't understand all the syntax (like """) and I also can't access to original spreadsheet to see what the references point to.

So, I'm looking for help in how to input the C3, C4, C5, etc into the JOIN -- not sure how the VLOOKUP helps me -- and also if anyone knows why there are so many ="&=&"""s throughout the suggested formula...

One of the solutions below may do what you need. The first is what you requested. The second is the one which will probably work to combine multiple IMPORTRANGE formulas.

SOLUTION 1 ="="&ArrayFormula(REGEXREPLACE(QUERY(UNIQUE(TRANSPOSE(SPLIT(CONCATENATE(IF(E3:E="","","IMPORTRANGE("&E3:E&", $E$1)"&":")),":"))),,9^99),"\\)(.*?)I","\\), I"))

SOLUTION 2 ="=QUERY({"&ArrayFormula(REGEXREPLACE(QUERY(UNIQUE(TRANSPOSE(SPLIT(CONCATENATE(IF(E3:E="","","IMPORTRANGE("&E3:E&", $E$1)"&":")),":"))),,9^99),"\\)(.*?)I","\\); I")&"},""Select Col1 where Col1<>''"",0)")

You would then just copy the cell, select the destination cell and "paste as values" into the formula bar .

You can see the sheet in action HERE (just make a copy of it to use).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM