Remove Empty Columns in Google Sheets Automatically

From my view the best way to remove empty for large sheets with many columns is by using Google Apps Script.

If you've never used Google Apps Script before, this is a great way to start. I'll guide you step by step through the process, and maybe from now on, you'll begin learning Google Apps Script to automate your everyday Google Sheets tasks.

Automatically remove empty columns #

To remove empty columns in Google Sheets, you can follow these steps:

  1. Click on Extensions > Apps Script.

  2. Replace the code in the script editor with the following:

    function deleteEmptyColumns() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var maxColumns = sheet.getLastColumn();
    for (var i = maxColumns; i >= 1; i--) {
    var range = sheet.getRange(1, i, sheet.getMaxRows(), 1);
    var values = range.getValues();
    var isEmpty = values.every(function(row) {
    return row[0] === "";
    });
    if (isEmpty) {
    sheet.deleteColumn(i);
    }
    }
    }
  3. Save the script and run the deleteEmptyColumns function by selecting it from the dropdown and clicking the play button.

This script will loop through the columns and delete any that are empty.

If you want to combine filtering with manual work, this is another method you can use.

Using a Filter to Identify and Delete Empty Columns #

  1. Select the entire data range or sheet by clicking the square icon between the A column and row 1 (this highlights the whole sheet).
  2. Go to the Data menu and select Create a filter.
  3. Now apply the filter by clicking on the filter icon at the top of each column.
  4. Scroll through the column filter options and deselect all values except for (Blanks).
  5. With only blank columns displayed, select these columns, right-click on one of the column headers, and choose Delete selected columns.

Manually Remove Empty Columns #

  1. Select the range of columns where you want to check for empty columns.
  2. Inspect each column and right-click on the column header of any empty column (e.g., Column A, B, etc.).
  3. From the context menu, select Delete column. This will remove the empty column.

Learn:

Published