I have a google sheet with a dynamically changing number of worksheets within it. I\'d like to be able to automatically union all worksheets that included in a named range that
without scripts you can build a formula generator in C1 like:
=ARRAYFORMULA({""; "={"&TEXTJOIN("; ", 1,
IF(A1:A="",,"QUERY("&A1:A&"!A2:C, ""where B != ''"")"))&"}"})
and then copy-paste C2 wherever you need
to skip re-copy-pasting you can use script:
function onEdit() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Contants");
var src = sheet.getRange("C2"); // The cell which holds the formula
var str = src.getValue();
var cell = sheet.getRange("C10"); // The cell where I want the results to be
cell.setFormula(str);
}
so it will copy generated "formulaa"-string from C2 and it will paste it in C10 as true formula so all you need to do is type in sheet names in A column and everything gets auto-updated