Created
August 21, 2013 02:14
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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")); | |
} |
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
One note on this: I believe you could do some magic to avoid code altogether with something like the arrayFormula function in Google Spreadsheets. I'm still using this, but I might get rid of it if I can. :)