How To Remove Blank Rows In Google Sheets

Google Sheets is a fantastic data analysis tool that allows you to manage, edit, and manipulate data in many ways. One common problem that users face is dealing with blank rows that can disrupt data analysis or the presentation of data. In this blog post, we will delve deep into the methods to remove blank rows in Google Sheets.

Manual Deletion

The simplest approach to deleting blank rows is to do it manually. This method is useful when you have a small dataset. To manually delete a row, right-click on the row number and select Delete row.
However, this can be time-consuming with larger data sets.

Using Google Sheets’ Built-in Function

Google Sheets has a built-in functionality specifically designed for cleaning up spreadsheets. The ‘Remove empty rows’ option can be found under the ‘Data’ menu. Here’s how to use it:

  1. Select the range of cells you want to consider.
  2. Click on Data from the menu bar.
  3. Hover over Remove empty rows and click on it.

Using Google Apps Script

If you’re dealing with a substantial dataset and need an automated solution, Google Apps Script can come in handy. Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products.

To remove empty rows using Google Apps Script, follow these steps:

  1. Click on Extensions -> Apps Script.
  2. On the Apps Script page, delete any code that’s in the code editor.
  3. Copy and paste the following code into the editor:

    function removeEmptyRows() {
        var sheet = SpreadsheetApp.getActive().getActiveSheet();
        var rows = sheet.getDataRange();
        var numRows = rows.getNumRows();
        var values = rows.getValues();

        var rowsToDelete = [];
        for (var i = 0; i < numRows; i++) {
            var row = values[i];
            var empty = true;
            for (var j = 0; j < row.length; j++) {
                if (row[j] != "") {
                    empty = false;
            if (empty) {

        for (var i = rowsToDelete.length - 1; i >= 0; i--) {
            sheet.deleteRow(rowsToDelete[i] + 1);

  1. Click on the disk icon or select File -> Save. Name your project and click OK.
  2. Run the script by clicking on the play icon. Google Sheets will prompt you for authorization, click Continue.
  3. Select your Google Account and click Allow.

After following these steps, all empty rows in your active sheet will be deleted.


Removing empty rows in Google Sheets can make your data easier to read and analyze. The method you choose to remove these blank rows depends on your specific needs and the size of your dataset. Happy data cleaning!