This script works and jumps from a user menu on tool bar to last row but since columns are A to Z, it always lands on the last row and in Column Z and I just navigate to the left to Column A

Is there a simple way to make it land in Column A instead of Z ?

function CountColA(){
  var sheet = SpreadsheetApp.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  for(var i = data.length-1 ; i >=0 ; i--){
    if (data[i][0] != null && data[i][0] != ''){
      return i+1 ;
function onOpen() {
  var spreadsheet = SpreadsheetApp.getActive();
  var menuItems = [
    {name: 'Go To End', functionName: 'goToEnd'}
  spreadsheet.addMenu('My Menu', menuItems);
function goToEnd() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();  
  var lastRow = sheet.getLastRow();
  var lastColumn = sheet.getLastColumn();
  var lastCell = sheet.getRange(lastRow, lastColumn);
  // Browser.msgBox('values: ' + lastRow + '-' + lastColumn);
  //sheet.setCurrentCell(lastRow);// <-- This of course does not work but would be preferred;

1 Answer 1


This worked

var lastCell = sheet.getRange(lastRow, 1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.