Skip to main content

How to remove empty rows and columns from tables in Word?

How can you remove the all empty rows and columns from tables in Word? This tutorial will show you several ways to remove empty rows and columns from tables in Word document.

Manually remove all empty rows and columns from tables

Remove all empty rows and columns from tables by using VBA code

Remove all empty rows and columns from tables with one clickgood idea3


Manually remove all empty rows and columns from tables

Microsoft Office Word does not provide a convenient way to remove empty rows and columns, and you need to remove them by manually select each empty row and column and then delete them one by one.

Step 1: Select the empty row or empty column you want to delete. See screenshot:

doc-removerowsandcols-1

Step 3: Under Table Tools, click the Layout Tab;

doc-removerowsandcols-2

Step 4: In the Rows & Columns group, click Delete Rows or Delete Columns.

doc-removerowsandcols-3


Remove all empty rows and columns from tables by using VBA code

The Macro Function of Word provides a much more convenient way to remove all empty rows and columns from tables in document. You can remove all empty rows and columns as follows.

Step 1: Press “Alt-F11” to open the Microsoft Visual Basic for Application window;

Step 2: Click Module on the Insert tab, copy and paste the following VBA code into the Module window;

Step 3: Then click Rundoc-reverse-sign-6 button to apply the VBA.

The VBA code to remove all empty rows and columns from tables:

Sub DeleteEmptyTablerowsandcolumns()
Application.ScreenUpdating = False
Dim Tbl As Table, cel As Cell, i As Long, n As Long, fEmpty As Boolean
With ActiveDocument
For Each Tbl In .Tables
n = Tbl.Columns.Count
For i = n To 1 Step -1
fEmpty = True
For Each cel In Tbl.Columns(i).Cells
If Len(cel.Range.Text) > 2 Then
fEmpty = False
Exit For
End If
Next cel
If fEmpty = True Then Tbl.Columns(i).Delete
Next i
Next Tbl
End With
With ActiveDocument
For Each Tbl In .Tables
n = Tbl.Rows.Count
For i = n To 1 Step -1
fEmpty = True
For Each cel In Tbl.Rows(i).Cells
If Len(cel.Range.Text) > 2 Then
fEmpty = False
Exit For
End If
Next cel
If fEmpty = True Then Tbl.Rows(i).Delete
Next i
Next Tbl
End With
Set cel = Nothing: Set Tbl = Nothing
Application.ScreenUpdating = True
End Sub


Remove all empty rows and columns from tables with one click

Kutools for Word provides you the most convenient way to remove all empty rows and columns from tables in document. You just need to click once, and Kutools for Word' s Delete Rows/Columns utility will remove all empty rows and columns from all or selecetd tables for you quickly.

Kutools for Word, with more than  handy functions, makes your jobs easier. 

After installing Kutools for Word, please do as below:(Free Download Kutools for Word Now!)

1. Click Kutools Plus > Delete Rows/Columns on the Table pane.

doc remove blank rows columns from table 1

2. Then a dialog pops out, choose the scope that you want to remove tables from in the Look in section, then check Row option and Blank row option, or check Column option and Blank row option as you need. If you want to delete all blank rows and columns, you need to apply this operation twice.

doc kutools remove blank rows 2  doc kutools remove blank rows 3 

Now a dialog pops out to remind you how many tables have been dealed with, click OK to close, and the blank rows and columns have been removed from tables.
doc kutools remove blank rows 4

Tip.If you want to remove blank rows from Excel sheet, the Delete Blank Rows utility of Kutools for Excel can help you.

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

🤖 Kutools AI Assistant: Transform your writing with AI - Generate Content  /  Rewrite Text  /  Summarize Documents  /  Inquire for Information based on Document, all within Word

📘 Document Mastery: Split Pages  /  Merge Documents  /  Export Selection in Various Formats (PDF/TXT/DOC/HTML...)  /  Batch Convert to PDF  /  Export Pages as Images  /  Print Multiple Files at once...

Contents Editing: Batch Find and Replace across Multiple Files  /  Resize All Pictures  /  Transpose Table Rows and Columns  /  Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces  /  Section Breaks  /  All Headers  /  Text Boxes  /  Hyperlinks  /  For more removing tools, head to our Remove Group...

Creative Inserts: Insert Thousand Separators  /  Check Boxes  /  Radio Buttons  /  QR Code  /  Barcode  /  Diagonal Line Table  /  Equation Caption  /  Image Caption  /  Table Caption  /  Multiple Pictures  /  Discover more in the Insert Group...

🔍 Precision Selections: Pinpoint specific pages  /  tables  /  shapes  /  heading paragraphs  /  Enhance navigation with more Select features...

Star Enhancements: Navigate swiftly to any location  /  auto-insert repetitive text  /  seamlessly toggle between document windows  /  11 Conversion Tools...

👉 Want to try these features? Kutools for Word offers a 60-day free trial, with no limitations! 🚀
Free Download     Read More     Buy Now
 
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi
Many many thanks. Its 100% worked.
This comment was minimized by the moderator on the site
Hi, thanks for the CODE, it worked on a document with only one table.

but when launching it on a word document with different tables from different sizes, i got this error : "Run-time error '5992' Cannot access individual columns in this collection because the table has mixed cell widths"

Can anybody help, please
This comment was minimized by the moderator on the site
Bonjour,

Quand j'exécute le programme, l'erreur suivante s'affiche " Erreur de compilation : Instruction incorrecte à l'extérieur d'une procédure"

Quelqu'un a une solution s'il vous plait ?
This comment was minimized by the moderator on the site
I found this macro and it works great when it comes to a table with single empty rows.
Is it possible to change it to work on a table with split rows as well?
I would very much thank you if you have a solution for me.
This comment was minimized by the moderator on the site
Hi, shimon, I don't not understand your question, please give me examples or describe the question with more details.
This comment was minimized by the moderator on the site
You just saved me a zillion hours of frustration, THANK YOU!
This comment was minimized by the moderator on the site
u know you can just resize the table right? just filter and sort your data to top check how many rows have data, click table tools and the click resize and adjust the last number to whatever you need OR go to the bottom of the table the very last cell and use the tine blue triangle to drag and resize,
This comment was minimized by the moderator on the site
Except I have multiple page document with a table with varying information in each. Furthermore, it is a merge document so different each week. I need an automated method :)
This comment was minimized by the moderator on the site
Hi, the macro is working, BUT:

After deleting all rows, all the columns of the tables with empty rows open up very wide.

How can i fix the code so that this does not happens?


I am using Office 2016.


Thank you!
This comment was minimized by the moderator on the site
Hi All, I am looking for function in word wherein, if I remove specific word then it should remove that row as well.
This comment was minimized by the moderator on the site
Thanks for the code, really useful.
This comment was minimized by the moderator on the site
Is there a macro that will delete a row if only one of the cells in that row is empty or contains a zero?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations