class SpreadsheetApp method .getNumRows()

SpreadsheetApp is the Apps Script service.

.getNumRows() is the method name you will see after a dot in your code.

What it does

Returns how many rows are in a range.

Why it's used

  • Loop the right number of times when processing a selected range.
  • Size arrays to match the range you are working on.

Common errors

  • Forgetting parentheses on getNumRows. Write SpreadsheetApp.getNumRows(), not SpreadsheetApp.getNumRows or getNumRows by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getNumRows().
  • Adding spaces where they do not belong. Write SpreadsheetApp.getNumRows(), not SpreadsheetApp .getNumRows(), SpreadsheetApp.getNumRows (), or SpreadsheetApp . getNumRows().
  • Wrong capitalization. Use SpreadsheetApp and getNumRows, not spreadsheetapp or getnumrows.

Explore

Related methods

  • .getNumColumns()

    Returns how many columns are in a range.

  • .getMaxRows()

    Returns the total number of rows the sheet can hold.

  • .getRow()

    Returns the starting row index of a range.

  • .getRange()

    Returns a range of cells by A1 notation or row and column numbers.

  • .getLastRow()

    Returns the row number of the last row that has content.

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.

Related blog posts

Written guides about SpreadsheetApp.getNumRows().

Browse the blog