3 Fast Ways to Delete Blank Rows and Columns in Your Word Table

In this post, we will explain to you 3 fast ways to delete blank rows and columns in your Word table.

Tables are essential to a document, especially in holding various types of data. Sometimes, a long table can exceed a page and extend over several. So once a table gets long and complicated, there are measures you can do to simplify it. For example, you can delete unnecessary blank rows and columns.Delete Blank Rows and Columns in Your Word Table

Following are 3 methods you can use.

Method 1: Delete Blank Rows and Columns Manually

  1. Firstly, select a row or a column in blank.
  2. Then right click to get the contextual menu. On the menu, select “Delete Rows” or “Delete Columns” accordingly.Select a Column->Right Click->Click "Delete Columns"

Unfortunately, you can’t select multiple non-consecutive rows or columns and delete them together with this way. For this demand, you can refer to our previous article: 5 Quick Methods to Batch Delete Multiple Rows or Columns in Your Word Table

Method 2: Batch Delete All Blank Rows and Columns in a Table

Method 1 has its limitation. So we will offer you the way to batch remove rows and columns in a table via VBA codes.

  1. To begin with, put cursor inside a target table.
  2. Second, trigger VBA editor by pressing “Alt+ F11”.
  3. In the editor, click “Normal” project first.
  4. Then click “Insert” tab on menu bar.
  5. On the drop-down menu, choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  6. Double click on module to open it and paste following codes there:
Sub DeleteBlankRowsAndTablesInATable()
  Dim objCell As Cell
  Dim nRowIndex As Integer, nRows As Integer, nColumns As Integer, nColumnIndex As Integer
  Dim varCellEmpty As Boolean
 
  Application.ScreenUpdating = False
 
  If Selection.Information(wdWithInTable) = False Then
    MsgBox ("Put cursor inside a table first!")
    Exit Sub
  Else
    With Selection.Tables(1)
      nRows = .Rows.Count
      For nRowIndex = nRows To 1 Step -1
        varCellEmpty = True
        For Each objCell In .Rows(nRowIndex).Cells
          If Len(objCell.Range.Text) > 2 Then
            varCellEmpty = False
            Exit For
          End If
        Next objCell
          If varCellEmpty = True Then
            .Rows(nRowIndex).Delete
          End If
      Next nRowIndex
 
      nColumns = .Columns.Count
      For nColumnIndex = nColumns To 1 Step -1
        varCellEmpty = True
        For Each objCell In .Columns(nColumnIndex).Cells
          If Len(objCell.Range.Text) > 2 Then
            varCellEmpty = False
            Exit For
          End If
        Next objCell
          If varCellEmpty = True Then
            .Columns(nColumnIndex).Delete
          End If
      Next nColumnIndex
    End With
  End If

  Set objCell = Nothing

  Application.ScreenUpdating = True
End Sub
  1. Finally, click “Run” button on menu bar or hit “F5”.Paste Codes->Click "OK"

In seconds, you will get all blank rows and columns in that table removed.

Method 3: Batch Delete All Blank Rows and Columns in All Tables in a Document

  1. First off, repeat steps in method 2 to install and run a macro.
  2. Only this time, replace that macro with the following:
Sub DeleteBlankRowsAndColumnsInAllTables()
  Dim objCell As Cell
  Dim objTable As Table
  Dim nRowIndex As Integer, nRows As Integer, nColumns As Integer, nColumnIndex As Integer
  Dim varCellEmpty As Boolean
 
  Application.ScreenUpdating = False
 
  With ActiveDocument
    For Each objTable In .Tables
      nRows = objTable.Rows.Count
      For nRowIndex = nRows To 1 Step -1
        varCellEmpty = True
        For Each objCell In objTable.Rows(nRowIndex).Cells
          If Len(objCell.Range.Text) > 2 Then
            varCellEmpty = False
            Exit For
          End If
        Next objCell
          If varCellEmpty = True Then
            objTable.Rows(nRowIndex).Delete
          End If
      Next nRowIndex
    Next objTable
 
    For Each objTable In .Tables
      nColumns = objTable.Columns.Count
      For nColumnIndex = nColumns To 1 Step -1
        varCellEmpty = True
        For Each objCell In objTable.Columns(nColumnIndex).Cells
          If Len(objCell.Range.Text) > 2 Then
            varCellEmpty = False
            Exit For
          End If
        Next objCell
          If varCellEmpty = True Then
            objTable.Columns(nColumnIndex).Delete
          End If
      Next nColumnIndex
    Next objTable
  End With

  Set objCell = Nothing
  Set objTable = Nothing

  Application.ScreenUpdating = True
End Sub

Recover Broken Document

There is more than a way to retrieve lost data back nowadays. For example, resorting to backups always remains your top priority. If that doesn’t satisfy your need to get the latest information back, you can then try a doc repair tool.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx repair and pdf repair software products. For more information visit www.datanumen.com

One response to “3 Fast Ways to Delete Blank Rows and Columns in Your Word Table”

  1. would it be possible to ask if a small modification could be made? My tables contain 2 columns. Column one simply contains a check box. Would it be possible to delete all rows in a table where the checkbox in column one has not been checked, and leave the row if the checkbox has been checked.

    thank you v much

Leave a Reply

Your email address will not be published. Required fields are marked *