I'm trying to insert a large number of columns into a table, I need to insert through 2 columns, now my code looks like this
sheet.insertColumnAfter(16),sheet.insertColumnAfter(18),sheet.insertColumnAfter(20),sheet.insertColumnAfter(22)
I tried to use an array, nothing worked, I will be very grateful
I believe your goal as follows.
insertColumnAfter(16)
, insertColumnAfter(18)
, insertColumnAfter(20)
and insertColumnAfter(22)
using Google Apps Script.insertColumnAfter(22)
to insertColumnAfter(16)
?
When above points are reflected to the script, it becomes as follows.
const sheet = SpreadsheetApp.getActiveSheet();
const columns = [16, 18, 20, 22];
columns.reverse().forEach(c => sheet.insertColumnAfter(c));