Reputation: 10784
I have a range in a google spreadsheet script.
var thisClientOutputRange = outputSheet.getRange(thisClientStartRow,thisClientStartColumn, monthsToSim + 3, 1);
Logger.log(thisClientOutputRange.getA1Notation());
The output is:
[15-10-29 18:43:06:461 GALT] B7:B57
Which is exactly the range I intended to address for this specific client (currently looping on in a for loop).
I can do
var thisClientOutputNameRange = thisClientOutputRange.getCell(1,1);
thisClientOutputNameRange.setValue(thisClientName);
And I can see the value correctly at B7
. Now the problem is if I try to do
var thisClientOutputNameRange = thisClientOutputRange.getCell(1,2);
I get the error Cell reference out of range
at exactly this line. I need to write something at C7
.
According to the getCell documentation:
var range = sheet.getRange("B2:D4");
// The row and column here are relative to the range.
//
getCell(1,1)
in this code returns the cell at B2, B2
I must have a very stupid mistake, but I can't find it. Any idea what could be going wrong with my logic?
thanks
Upvotes: 0
Views: 3037
Reputation: 3335
The range's getCell(row,column) method returns a cell from the range. The row and column coordinates are relative to the range. In your example of getCell(1,2), row=1 and column=2 represents the cell at the first row and second column of the range. However, the range B7:B57 only has one column. Thus, the cell reference is outside of the range.
Upvotes: 1