Created
October 12, 2012 22:09
-
-
Save wskidmore/3881871 to your computer and use it in GitHub Desktop.
Get Column Range by Start Row Index, google script for spreadsheets
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
// example usage | |
function testGetFullColumn() | |
{ | |
Logger.log(getFullColumn('A', 1).getNumRows()); // number rows A1:A end | |
Logger.log(getFullColumn('B', 2).getNumRows()); // number rows B2:B end | |
Logger.log(getFullColumn('C', 5).getNumRows()); // number rows C5:C end | |
// also look into: | |
// https://developers.google.com/apps-script/storing_data_spreadsheets#reading-2 | |
// for converting a range into js objects for easier calculations | |
} | |
// This function gets the full column Range like doing 'A1:A9999' in excel | |
// @param {String} column The column name to get ('A', 'G', etc) | |
// @param {Number} startIndex The row number to start from (1, 5, 15) | |
// @return {Range} The "Range" object containing the full column: https://developers.google.com/apps-script/class_range | |
function getFullColumn(column, startIndex){ | |
var sheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var lastRow = sheet.getLastRow(); | |
return sheet.getRange(column+startIndex+':'+column+lastRow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment