pasting an array in a column

324 views
Skip to first unread message

Somnath Bhattacharya

unread,
Jan 5, 2023, 4:56:25 AM1/5/23
to Google Apps Script Community
I have an array with data which reads like 1,2,3,.......600.  I want to paste this array in a column (which I can choose where I want to paste) with a single line command such as setValues. How can I do that ? Any help will be much appreciated. 

Edward Ulle

unread,
Jan 5, 2023, 11:01:33 AM1/5/23
to Google Apps Script Community
Transform a 1D array to a 2D array.

let a = [1,2,3,4,5];
let b = a.map( v => [v] );
console.log(b);

7:57:56 AM Info [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ]

sheet.getRange(1,1,b.length,1).setValues(b);
Reply all
Reply to author
Forward
0 new messages