Michelle
Michelle

Reputation: 46

How to Limit the Amount of Rows in Google Apps Script?

Similar to the limit formula in Google Sheets:

=query(F1:F, "select F where F contains '5' limit 10")

How would I limit the amount of returning rows in Google Apps Script, when I want to limit the results? Here is what I have where it pastes my return rows, and the function works correctly, but I need to limit the results to 20:

 ws.getRange(6, 11, rows.length, rows[0].length).setValues(rows);

Any suggestions?

Upvotes: 0

Views: 1231

Answers (1)

Cooper
Cooper

Reputation: 64032

Limiting Rows

var r=rows.slice(0,20);
ws.getRange(6, 11, r.length, r[0].length).setValues(r);

Array.slice

Upvotes: 1

Related Questions