问题
I have a Google Sheets that collects marks of students from various sheets to create a complete mark sheet. Each teacher enters marks in his/her own spreadsheet with paper number as sheet names. Each sheet of any has just two columns: Roll#
and Marks
. Using combination of paper number (sheet name), Google Sheets Key, Roll#
and Marks
I MANUALLY create formulas to collate data using Sort, ArrayFormula and IMPORTRANGE functions. This works.
But manually creating formulas is an error prone approach. Plus, I want to teach each teacher how to do this.
What I want is to add formula in cell G23 so that it creates IMPORTRANGE dynamically based on the entries in cells G2:G22 above it. If there are three names, it creates three IMPORTRANGEs, if there are five names, it creates five IMPORTRANGEs dynamically so that these IMPORTRANGEs are merged by enveloping ArrayFormula and sorted.
Existing formula is what I created manually and it works. All I want is to have the formula so that if a new teacher name is added in G2-G22, a new IMPORTRANGE is added within ArrayFormula.
回答1:
As the importrange function has the ability to output arrays, it can't be iterated across an array.
To combine your formula, use this formula:
="=sort(ARRAYFORMULA({"&JOIN(";",ArrayFormula("IMPORTRANGE("""&VLOOKUP(FILTER(G2:G20,G2:G20<>""),Sheet3!$A$2:$B,2,0)&""","""&G1&"!A2:B"")"))&"}),1,True,2,True)"
then you could paste the result in G23 manually or use script to paste formula
来源:https://stackoverflow.com/questions/36198117/fill-arrayformula-with-dynamic-importrange