У меня есть таблица Google, в которую данные добавляются из таблицы слияния с использованием сценария, приведенного в этой ссылке на github. Я добавил еще два столбца в правом конце таблицы, один из которых заполняется формулой
=COUNTIF(A$2:A$24,A2)
и другой столбец по другой формуле. В настоящее время, когда каждый раз, когда таблица обновляется новыми строками, я вручную перетаскиваю столбцы формул, чтобы обновить данные в них. Можно ли динамически обновлять столбцы формул с помощью скрипта ?. Т.е. при добавлении строк столбец формулы также обновляется динамически.
РЕДАКТИРОВАТЬ:
// evaluate project type and set identifier
function addCountIfFormulaToCell(){
// add the id of your spreadsheet here
var sss = SpreadsheetApp.openById('0AozvCNI02VmpdG5tb0pkUGdDR3djMm5NV0pYeThFbGc');
// add the name of the sheet here
var ss = sss.getSheetByName('Sheet1');
// column you want to evaluate for the formula
var columnToEvaluateAgainst = "A";
// column you want to add the formula to
var columnToAddFormulaTo = "H";
// identifies the last row
var lastRow = ss.getLastRow();
// is the cell to evaluate in the last row
var evaluateThisCell = columnToEvaluateAgainst + lastRow;
// is the cell that gets the forumla in the last row
var addFormulaToThisCell = columnToAddFormulaTo + lastRow;
// this is my formula
var projectFormula = "COUNTIF(A$2:$A,A2)";
// grabs the cell that gets the forumla in the last row
var ssCellToGetFormula = ss.getRange(addFormulaToThisCell);
// sets the formula to the cell in the last row
ssCellToGetFormula.setFormula(projectFormula);
};