I see some people have had similar issues in the past, but they seems to be just different enough for the solution to be different. So here goes:
I'm trying to return a range of known size in Google Apps Scripts for sheets like so:
var myRange = ss.getRange(2,1,14,4);
However, I'm getting an error like this:
Cannot find method getRange(number,number,number,number).
Note that using a1notation, as shown below, works just fine:
var myRange = ss.getRange("A2:D15");
The getRange
function has several permutations
- getRange(int, int)
- returns a range from the coordinates of the ints
- getRange(int, int, int)
- returns a range from the coordinates of the first 2 parameters of as many rows as the last parameter
- getRange(int, int, int, int)
- returns a range from the coordinates of the first 2 parameters of as many rows as the 3rd parameter and as many columns as the last parameter
- getRange(string)
- returns a range specified by the string in a1notation (i.e. "A2:D15", which is the same as saying everything from row 2 column 1 to row 15 column 4)
I've tried using all the different permutations (using hard-coded numbers), and only the a1notation one works. Any thoughts?
ss
was defined. Perhaps it's only looking at the active spreadsheet and not a sheet within it. – Munkey