Google Sheets – How to Bulk Remove Columns from Different Worksheets

google sheets

I think I have a pretty simple problem but I just can't seem to find the solution for it.

I basically know how to bulk remove columns in the same sheet, except I'm now working in multiple sheets and would like to remove columns in all of them.

A concrete example would be:

I want to remove column A from all of my 20 worksheets.

How do I go about this? Tried add-ons but didn't seem to find any that did the trick. Are formulas the way to go – can anyone point me in the right direction?

Best Answer

Use the following script, entering it under Tools > Script Editor.

function removeColumnA() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  for (var i = 0; i < sheets.length; i++) {
    sheets[i].deleteColumn(1);
  }
}

It loops through the sheets of the current spreadsheet, deleting the first column in each.

If this is something you do often, instead of opening the editor each time to run the script, add another function that will automatically add a menu item "Custom > Delete First Columns" each time the spreadsheet is opened.

function onOpen() {
  SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", [{
    "name": "Delete First Columns", 
    "functionName": "removeColumnA"
  }]);
}