Google Sheets Dynamic URL pass to ImportRange() formula?

77 views Asked by At

For simplicity, assume I would have a folder in Google Disk for each of 12 months. So 12 folders. In each there are 2 Google Sheets. One is report sheet. Another is source sheet. So 2 sheets in a folder.

In a report sheet, for example, I use this formula:

=IF(COUNTBLANK(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1", "Sheet1!B9:D9")) > 0, 1, "")

So it uses IMPORTRANGE() and access source sheet by its URL which is the source file access link. Report sheet take data from source sheet and formula do some calculations. This simple example just for simplicity.


Next, I need co create a copy of this directory (with 2 sheets inside) in Google Disk Drive. First folder was January. Then I create new Folder February with copies of two Google sheets inside. But formulas with ImportRange() still link to sheets in first "January" folder. So to fix it I need to change URLS in importRange() and change links to source file in February folder manually. In reality I have lots of sheets inside each month folder so doing it manually is impossible.


How to pass dynamic URL to ImportRange() formula in report sheet. So, if I create copy of this directory (January folder) in Google Disk for another month links inside new sheets link to a new generated source file (not initial one in previous folder)? Is it possible to pass dynamic URL of a file within current directory for a source file sheet for importRange() formula?

0

There are 0 answers