I'm trying to use a javascript call to update the value in one cell, based on an offset from a cell I've found to contain a particular value.
For example, I'd like to iterate through column A
until I find "bar", then set the value of the B
column in that row to 1
:
I know how to read the values in the first place:
gapi.client.sheets.spreadsheets.values.get({
spreadsheetId: SPREADSHEET_ID,
range: 'Sheet1!A1:A3',
}).then(function(response) {
var range = response.result;
for (i = 0; i < range.values.length; i++) {
if (range.values[i] == "bar") {
// Update column B in this row to 1
}
And I know I need some kind of invocation of spreadsheets.values.update
:
gapi.client.sheets.spreadsheets.values.update({
spreadsheetId: SPREADSHEET_ID,
range: the range found above, offset by one column,
valueInputOption: 'RAW',
values: [ [ value ] ]
});
But how can I get the address offset from the range found in the code above?