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.
Snippets using this method
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
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 →Spreadsheets Explained! 5 Levels of Difficulty: From Basic Text Input to Google Apps Script
Five increasingly difficult ways of explaining spreadsheets in Google Sheets: The basics of Google Sheets text Menu items in Google Sheets Math inside Google Sheets Using Formulas in Google Sheets Apps Script in Google Sheets
Read post →