If there is a column of 10 full cells in a row, and you go to the top of the column and hit command + down arrow, it activates the lowest non-empty cell.

I tried to record a macro while using cmd + down arrow, but instead of activating the lowest non-empty cell, it just activates the same cell over and over. I tried .getLastRow().

How do I move to the lowest non-empty cell in a column, or how do I replicate the cmd + ↓ behavior?

  • Hi and welcome to WebApps. You said you tried .getLastRow(). Would you please show the code that you tried. .getLastRow() has a context for a range and a different context for a sheet. So whether and why it didn't work would depend on how your wrote your code. Also, .getLastRow() doesn't move the cursor, it just creates a target; you have to set an active range that is defined by .getLastRow()
    – Tedinoz
    Dec 31, 2021 at 2:21
  • 1
    Does this answer your question? Quickly scroll to the last row with data in Google Sheets on a Mac
    – Tedinoz
    Dec 31, 2021 at 2:21

1 Answer 1


Use getNextDataCell(), like this:

  const spreadsheet = SpreadsheetApp.getActive();  
    .offset(1, 0)
  • I see. That works. Thank you :) But that takes me to the bottom most cell with characters in it. How do I go one cell down from that?
    – aishlia
    Jan 3, 2022 at 4:39
  • Sorry, I figured it out. I'm very new to this (obviously). I just did: spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate(); spreadsheet.getCurrentCell().offset(1,0).activate();
    – aishlia
    Jan 3, 2022 at 4:50
  • I gather that this is your first question at Stack Exchange. See What should I do when someone answers my question? Jan 4, 2022 at 20:47

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.