I've a Google spreadsheet to which data is added from a fusion table using the script given in this github link. I added two more columns at the right end of the spreadsheet in which one is filled using formula
=COUNTIF(A$2:A$24,A2)
and other column by another formula. Currently, when every time the spreadsheet is updated with new rows, I am manually dragging the formula columns to update the data in them. Is it possible to update formula columns dynamically using script?. Ie, when the rows added the formula column also updated dynamically.
EDIT:
// 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);
};