Using IMPORTRANGE, INDIRECT, and CONCATENATE together

╄→гoц情女王★ 提交于 2021-02-08 06:35:35

问题


I have a sheet that pulls numbers from several different sheets to amalgamate numbers. Each week, a new sheet is added to the source files, all with the same name. I'd like to update the amalgamated sheet by changing one cell instead of many. When the tab is located in the same Google sheet, this is easily done with INDIRECT.

Right now, the formula in the amalgamated sheet is:

=IMPORTRANGE(M4, "Aug29!$F$2")

That formula is on each line to pull from several different sheets:

=IMPORTRANGE(M5, "Aug29!$F$2")
=IMPORTRANGE(M6, "Aug29!$F$2")

and so on.

Each week, the "Aug29" changes to the new date - "Sep5", "Sep12", etc.

What I'd like to do is use INDIRECT to pull that part of the equation in (from cell Z1) so that I don't have to update each formula.

I was thinking I could use CONCATENATE to create the "Aug29!$F$2" portion of the formula with INDIRECT:

=IMPORTRANGE(M4, CONCATENATE(INDIRECT(Z1), "!$F$2"))

The problem is, the IMPORTRANGE formula requires quotations around the range string, and I can't figure out how to add them.

Weird problem, I'm sure, but wondering if there's anyone with a solution?


回答1:


UNTESTED. Please try something like:

=IMPORTRANGE(M4,Z$2)  

with in Z2 something like:

=Z1&"!$F$2"  

In other words, I think your IMPORTRANGE does not like INDIRECT.




回答2:


Short answer

Use =IMPORTRANGE(M4, CONCATENATE(Z1, "!$F$2")) or =IMPORTRANGE(M4, Z1&"!$F$2")

Explanation

INDIRECT requires a string that represents a cell or range references, like "Z1" but it will increase unnecessarily the complexity of your formula.

If Z1 has the name of the sheet, then just concatenate it by using CONCATENATE, CONCAT or &



来源:https://stackoverflow.com/questions/39259223/using-importrange-indirect-and-concatenate-together

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