Skip to content

Instantly share code, notes, and snippets.

@jcamenisch
Created August 21, 2013 02:14
Show Gist options
  • Save jcamenisch/6289678 to your computer and use it in GitHub Desktop.
Save jcamenisch/6289678 to your computer and use it in GitHub Desktop.
To be triggered on form post in a Google Spreadsheet. This simple function will copy calculations from an early row to the rest of the rows (including the blank row that was newly inserted by the form post).
// How I had it as of this morning, 8/20/2013
var _inputSheet;
function inputSheet() {
return _inputSheet || (
_inputSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Input')
);
}
function continueFormulas() {
var source_range = inputSheet().getRange("G3:N3");
var target_range = inputSheet().getRange("G3:N");
source_range.copyTo(target_range);
}
// How one might rewrite it to be more direct
function continueFormulas() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Input')
sheet.getRange("G3:N3").copyTo(sheet.getRange("G3:N"));
}
@jcamenisch
Copy link
Author

On second thought: ArrayFormula is a really sweet tool in Google Spreadsheets (I'm not sure if a similar function exists in the established desktop spreadsheet apps). However, I can't figure out how to do running aggregations with it, so I'm going to stick with my App Script hack for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment