Fill ArrayFormula with dynamic IMPORTRANGE

佐手、 提交于 2019-12-20 05:58:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!