Reputation: 13342
I am new to this. Checked docs, googled, but could not find what I wanted as easy.
With Google Apps Script,
I would like to get a cell object that is close to the left of current one.
var sheet = SpreadsheetApp.getActive();
var cell = sheet.getCurrentCell()
// var priceColumn = cell.getColumn()-1;
// var strategyColumn = cell.getColumn()-2;
cell.left?
Basically I would need to navite lef and right, up and down from the curent cell..?
Upvotes: 0
Views: 1031
Reputation: 27348
You are looking for the offset function:
Examples:
var sheet = SpreadsheetApp.getActive();
var cell = sheet.getCurrentCell();
var newCell = cell.offset(0, 1); // cell to the right
var newCell = cell.offset(0, -1); // cell to the left
var newCell = cell.offset(1, 0); // cell below
var newCell = cell.offset(-1, 0); // cell above
offset(rowOffset, columnOffset)
:
Upvotes: 2