Returns a range shifted by a number of rows and columns.
class SpreadsheetApp method .offset()
SpreadsheetApp is the Apps Script service.
.offset() is the method name you will see after a dot in your code.
What it does
Why it's used
- Move one cell over to grab the value next to a label.
- Slide a range down a row for week-over-week comparisons.
Common errors
- Forgetting parentheses on offset. Write SpreadsheetApp.offset(), not SpreadsheetApp.offset or offset by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').offset().
- Adding spaces where they do not belong. Write SpreadsheetApp.offset(), not SpreadsheetApp .offset(), SpreadsheetApp.offset (), or SpreadsheetApp . offset().
- Wrong capitalization. Use SpreadsheetApp and offset, not spreadsheetapp or offset.
2 Snippets using this methods
Explore
Related methods
-
.getRow()
Returns the starting row index of a range.
-
.getRange()
Returns a range of cells by A1 notation or row and column numbers.
-
.getColumn()
Returns the starting column index of a range.
-
.getNumRows()
Returns how many rows are in a range.
-
.setValues()
Writes a 2D array of values into a range of cells.
More Apps Script
2 Better Sheets tutorials
2 New Ways To Add Emoji Reactions
Related blog posts
Written guides about SpreadsheetApp.offset().
How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
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 →How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →