Google Sheets – Sum Values Across Multiple Sheets IDs Automatically

google sheetsgoogle-apps-scriptgoogle-sheets-query

I used this post to have all Google Sheets IDs in a folder
Getting all files' file-id from a folder in Google Drive

I would like to make a formula or script to sum values in table across all these sheets IDs (note, the table is present in all sheets with same cell range).

Instead of copying and pasting the sheets Ids manually every time, I would like to make formula with variables that represents sheets ID so that every time I just past the sheets ID and the variables are assigned for each sheets.

Some thing in my mind like this:

a=1bsKy3bx9x2sYbM4BBvUjaYDdtveL1XV1l8wp8-CUD1c

b= 1fUb8H44PpeZpu40mfzK1_vuNEoLAyhiHjNcSOGTfLJU

c=1CckyrVFklIdQZa6PCM6mByvV9UK14zEwnoaK0PueTHg

And so on… while the formula is fixed

Best Answer

You can do the following set-up

In cell C2 place ="'statistics'!d6" and so on

Then in cell D2 the below formula and drag it down

=SUM(IMPORTRANGE($B$2, C2),IMPORTRANGE($B$4, C2))

enter image description here