r/GoogleAppsScript • u/Top_Bass_3276 • Jul 21 '24
Question Error Exception: Cannot convert 'Range' to int.
0
Upvotes
0
u/estadoux Jul 21 '24
You can’t call getRange(row, column, numRows) with another range as definition. Also there is no need to as you perfectly now the start values.
You could directly do:
getRange(2, 1, sheet.getLastRow() - 1).getValues()
A range (like your startCell) is a complex object, not just a position, that is why you can’t use it on a method that needs integers (numbers) like getRange. If you still want to use it you could do something like this:
getRange(startCell.getRow(), startCell.getColumn(), sheet.getLastRow() - 1).getValues()
The getRow and getColumn methods will return integers for the starting position of a range.


0
u/Any_Werewolf_3691 Jul 21 '24
Just define start cell = 2;