Answer the question
In order to leave comments, you need to log in
String automation?
You need to write a formula:
spreadsheet.getRange('C 2 ').activate();
spreadsheet.getCurrentCell().setFormula('=IMPORTRANGE(" https://docs.google.com/spreadsheets/d/ "; "Indicator!C 2 ")');
1240 times. Increasing the selected values by 1.
That is, in each subsequent cell, a formula should be obtained that differs in the cell number by 1.
Example:
spreadsheet.getRange('C2').activate();
spreadsheet.getCurrentCell().setFormula('=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C2")');
spreadsheet.getRange('C3').activate();
spreadsheet.getCurrentCell().setFormula('=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C3")');
spreadsheet.getRange('C4').activate();
spreadsheet.getCurrentCell().setFormula('=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C4")');
Answer the question
In order to leave comments, you need to log in
Hard, metallic (c)
You can do it like this:
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C2:C")
const formulaTemplate = '=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C2")';
let range = spreadsheet.getRange('C2:C1240');
let formulas = range.getFormulas();
formulas = formulas.map((row,ri)=>row.map(f=>formulaTemplate.replace('!C2', '!C'+(ri+2))));
range.setFormulas(formulas);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question