Sheet.getRange(1,1,1,12) what does the numbers in bracket specify?

Sneha Grewal picture Sneha Grewal · Aug 14, 2012 · Viewed 149.6k times · Source
Sheet.getRange(1,1,1,12)

I cannot understand the arguments 1,1,1,12 . What is this - the sheet id or row or what?

method getRange(row, column, optNumRows, optNumColumns)

here what does optNumRows and optNumColumns mean???

Answer

Terry picture Terry · Aug 14, 2012

Found these docu on the google docu pages:

  • row --- int --- top row of the range
  • column --- int--- leftmost column of the range
  • optNumRows --- int --- number of rows in the range.
  • optNumColumns --- int --- number of columns in the range

In your example, you would get (if you picked the 3rd row) "C3:O3", cause C --> O is 12 columns

edit

Using the example on the docu:

// The code below will get the number of columns for the range C2:G8
// in the active spreadsheet, which happens to be "4"
var count = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getNumColumns(); Browser.msgBox(count);

The values between brackets:
2: the starting row = 2
3: the starting col = C
6: the number of rows = 6 so from 2 to 8
4: the number of cols = 4 so from C to G

So you come to the range: C2:G8