Add a new column before and after in sheets

function addColumn() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheets()[0];
const sheetName = sheet.getName();
sheet.insertColumnBefore(1);
const lastCol = sheet.getMaxColumns();
sheet.insertColumnAfter(lastCol);
sheet.getRange(1,1).setValue(‘FIRST’);
sheet.getRange(1,lastCol+1).setValue(‘LAST’);
Logger.log(lastCol);
}

https://github.com/lsvekis/Google-Apps-Script/blob/main/2023Apr/Add%20a%20new%20column%20before%20and%20after%20in%20sheets

WP Twitter Auto Publish Powered By : XYZScripts.com