I am having an issue with inserting a column after my last column. I am using the below code, but I have blanks all throughout my data so it is inserting a column about halfway through. It is confusing because row 1 is completely full all the way until the end so I figured that would trump the blank cells throughout, but it is still inserting a column halfway through.
function AddColumn() {
var ss = SpreadsheetApp.openById("spreadsheetId");
var sheet2 = ss.getSheetByName("sheetName");
sheet2.insertColumnAfter(sheet2.getLastColumn());
}
Thank you for any help!
It's not the best way but
function AddColumn() {
var ss = SpreadsheetApp.openById("spreadsheetId");
var sheet2 = ss.getSheetByName("sheetName");
sheet2.insertColumnAfter(sheet2.getDataRange().getValues()[0].length);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.