Skip to content

Instantly share code, notes, and snippets.

@phillypb
Last active December 16, 2018 21:04
Show Gist options
  • Save phillypb/c4215a1b8da5287a524f82c87c6ee9bd to your computer and use it in GitHub Desktop.
Save phillypb/c4215a1b8da5287a524f82c87c6ee9bd to your computer and use it in GitHub Desktop.
function getActiveCell() {
// get the active spreadsheet and sheet
var ss = SpreadsheetApp.getActiveSpreadsheet(); // ss contains entire spreadsheet
var sheet = ss.getActiveSheet(); // sheet contains current active sheet ('Students')
// from sheet, get active cell and store as variable
var activeCell = sheet.getActiveCell();
// from activeCell, get value and store as variable
var cellValue = activeCell.getValue();
// show value of cellValue
Logger.log(cellValue);
// from activeCell, also show row number
var cellRow = activeCell.getRow();
Logger.log(cellRow);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment