¿Qué debo cambiar para que este script establezca las fórmulas (desde la fila 2) al rango definido? El siguiente código no me da ningún error, pero no establece las fórmulas en absoluto.
var lc = sheet.getLastColumn(); var range = sheet.getRange(2, 1, 1, lc); var formulas = range.getFormulas(); range.copyFormatToRange(sheet, 1, lc, 3, 3+response); //This pastes the format to the range, whose number of rows is defined depending on the # that the user inputs. var pasteTo = sheet.getRange(3, 1, response, lc);//Defines the range for setting formulas for (var a = 3; a < response; a++){ pasteTo = sheet.getRange("A" + a,sheet.getLastColumn()); pasteTo.setFormulas(formulas); } } } function kdkdkd() { const ss = SpreadsheetApp.getActive(); const sh = ss.getSheetByName('Sheet0'); const osh = ss.getSheetByName('Sheet1'); const fA = sh.getRange(2, 1, sh.getLastRow() - 1, sh.getLastColumn()).getFormulas(); osh.getRange(row,col,fA.length,fA[0].length).setFormulas(fA); }elige lo que quieras para fila y columna
Gracias, @TheMaster, por la orientación: la firma es .getRange('string') (a1notación) o .getRange(number,number) (fila, columna), pero no hay .getRange('string',number)
Así es como lo resolví:
var lc = sheet.getLastColumn(); var range = sheet.getRange(2, 1, 1, lc); var formulas = range.getFormulas(); range.copyFormatToRange(sheet, 1, lc, 3, 3+response); var pasteTo = sheet.getRange(3, 1, response, lc); for (var a = 1; a <= response; a++){ pasteTo = sheet.getRange(a+2,1,1,lc); pasteTo.setFormulas(formulas); } } }