Insert or add a column

Here is a tip how to add a column.

 

Source code

function insertCol() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();

  sh.insertColumns(4);
  sh.insertColumnAfter(1);
  sh.insertColumnBefore(1);
}

 

Format

SheetObject.insertColumns(columnIndex)
SheetObject.insertColumnAfter(afterPosition)
SheetObject.insertColumnBefore(beforePosition)

 

Parameters

(1) insertColumns

columnIndex … The target column’s number. New column will be added after this target column.

(2) afterPosition

afterPosition … The target column’s number. New column will be added after this target column. (This is same with “columnIndex”)

(3) beforePosition

beforePosition … The target column’s number. New column will be added before this target column.

 

Responses

None

Leave a Comment