Created
March 10, 2013 19:48
-
-
Save j100002ben/5130126 to your computer and use it in GitHub Desktop.
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
| /** | |
| * The onOpen() function, when defined, is automatically invoked whenever the | |
| * spreadsheet is opened. | |
| * For more information on using the Spreadsheet API, see | |
| * https://developers.google.com/apps-script/service_spreadsheet | |
| */ | |
| function onOpen() { | |
| var sheet = SpreadsheetApp.getActiveSheet(); | |
| var b_col = sheet.getRange('B:B'); | |
| var g_col = sheet.getRange('G:G'); | |
| var num_rows = g_col.getNumRows(); | |
| Logger.log(num_rows); | |
| var values = g_col.getValues(); | |
| var formulas = []; | |
| for (var i = 0; i < num_rows; i++){ | |
| Logger.log(values[i][0]); | |
| formulas[i] = formulas[i] || []; | |
| if (values[i][0] != ''){ | |
| formulas[i][0] = '=G' + (i+1).toString(); | |
| }else{ | |
| formulas[i][0] = ''; | |
| } | |
| } | |
| b_col.setFormulas(formulas); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bravo