Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9831

Move row to very bottom of sheet (Google Sheets Apps Script)

$
0
0

I have a google sheet with a specific number of rows, and I want to use a script/macro to move a certain row to the very bottom.

screenshot1

const DESTINATION_INDEX = 4;function myFunction() {  const ss = SpreadsheetApp.getActive();  const foo = ss.getRangeByName('foo');  foo.getSheet().moveRows(foo, DESTINATION_INDEX);}

That causes it to end up at row 3 (as the moveRows() documentation and example suggest):screenshot2

But when DESTINATION_INDEX = 5, it throws Exception: Those rows are out of bounds.

I could work around this by moving foo to the penultimate row, then moving the last row up by one. Or I could do a little insertRowAfter/deleteRows dance.
But is there any way to move a row directly to the bottom? This seems like an oversight in the API.


Viewing all articles
Browse latest Browse all 9831

Latest Images

Trending Articles



Latest Images