Returns how many rows are in a range.
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
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.
More Apps Script
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().
Automate Row Deletion in Google Sheets with Apps Script
In this post, we'll cover how to remove rows automatically in Google Sheets using Apps Script, ensuring you save time and streamline your spreadsheet management. You're probably already familiar with the manual way of right-clicking and deleting rows, but there's a more efficient way to handle this—automation! Manual versus Semi-Automatic Deletion You may know that you can manually delete rows in Google Sheets by right-clicking and selecting "Delete row." You can even select multiple rows...
Read post →How To Use a 1-Cell Google Sheet
Introduction to Tiny Sheets a free google sheet add-on to make tiny spreadsheets. Delete unnecessary rows and columns easily.
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →