Google-sheets – Google Sheets – Using IMPORTRANGE with a variable number of rows

google sheetsgoogle-sheets-arrayformulagoogle-sheets-query

Google Sheets – Using IMPORTRANGE with a variable number of rows
…is it possible to add the required number of blank rows to avoid the IMPORTRANGE's overwrite error?

Test Input: https://docs.google.com/spreadsheets/d/1xEGDDG3BiXHtkU7r8M8uKbyhO9zUKLslKmC5NBK2B8A/edit?usp=sharing

Test Database: https://docs.google.com/spreadsheets/d/1_YZM1INB2VxLFiV60U8koqPLFxhPmDbea2oviM4Dks8/edit#gid=0

In the Test Database sheet, I have a function in B2 that will retrieve the rows of data from Test Input. This function will figure out how many rows there are and insert the appropriate amount. The difficulty is that if I leave that function in each row in column B, then when a link is dropped into column A to work as the IMPORTRANGE source, it will error because the cells that the function now want to fill have the next functions in the way. I am hoping that there's something I can add to the function so that it creates and inserts the appropriate amount of blank rows to avoid that error. Alternatively, a way that when the function runs, it deposits a fresh version of the function in the next available cell in column B.

Any help would be super appreciated.

/edit: Someone asked for additional unique input docs:
Doc2 https://docs.google.com/spreadsheets/d/1Gj4-DeZCs8D9iFkFrcSM6kHL_78pGvXPorvjn-aXdpY/edit#gid=0
Doc3 https://docs.google.com/spreadsheets/d/12DAvPs1TVDTuxs0VDZUPRBQuRhyVeOdhgukxNk29vQw/edit#gid=0
Doc4 https://docs.google.com/spreadsheets/d/1cDegqQ63VtSSMUFR8pBW9z8A430NZ6z3hTVJFnFctu8/edit#gid=0

Best Answer

This formula, Dragged down in column B:

=ARRAYFORMULA(IF(A2="",,QUERY(QUERY(IMPORTRANGE(A2,"Sheet1!B2:F10"), "select * where Col1 is not null" )&"|",,9^99)))

And then this formula just one time in cell H2:

=ARRAYFORMULA(TRANSPOSE(TRIM(SPLIT(TRANSPOSE(QUERY(B2:F,,9^99)),"|"))))

Should allow you to build the aggregated dataset you're looking for.