How to Remove Empty Rows at the End of an Excel Table with VBA
Question details
The user needs a method to eliminate unused empty rows that persist at the end of an Excel table using VBA, or diagnose why they are continuously generated.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Running existing VBA macros or applying specific table formatting results in empty, unused records being left at the bottom of a data table.
- Observed behavior
- Empty rows remain attached to the bottom of the table (ListObject), causing issues with data processing, filtering, and printing.
Before running any VBA macros or deleting table rows, ensure you have saved a backup of your workbook, as VBA actions bypass the undo history and cannot be reverted.
Use a VBA Macro to Delete Empty ListRows
Run a dedicated VBA script to loop through the table and delete any rows where the contents are entirely blank.
In Excel, tables are treated as ListObjects. If a macro clears the cell contents without deleting the actual ListRow, the table retains an empty row at the bottom. A cleanup script can resolve this.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications editor.
Click on 'Insert' in the top menu and select 'Module' to create a blank script window.
Write a VBA loop targeting your specific ListObject (e.g., ActiveSheet.ListObjects("Table1")). Instruct the script to loop backwards from the last row (ListRows.Count) and use the '.Delete' method if the row is empty.
Press F5 or click the Run button to execute the code and instantly strip the empty rows from the bottom of your table.

Diagnose Workbook-Specific VBA Behavior with a Sample File
If empty rows keep returning, the issue may stem from conflicting formatting or another macro. Creating a safe sample file helps isolate the root cause.
Remove Blank Rows Instantly with WPS Spreadsheet
Skip the complex VBA coding. WPS Spreadsheet offers highly intuitive, built-in tools to manage tables and instantly delete blank rows from your datasets without any programming knowledge.
- 1. Open Your File in WPS: Launch WPS Spreadsheet and open your existing Excel workbook containing the table.
- 2. Select the Table Range: Click and drag to highlight your table, or simply select the columns containing the unwanted blank rows.
- 3. Use Go To Special: Navigate to the 'Home' tab, click on 'Find and Replace', select 'Go To', and check the 'Blanks' option to highlight all empty cells.
- 4. Delete Empty Rows: Right-click on any of the highlighted blank cells, select 'Delete', and choose 'Entire Row' to clean up your table instantly.

Frequently Asked Questions
Why does my Excel table automatically expand with blank rows?
Excel tables (ListObjects) are designed to auto-expand when data is entered directly below them or when certain formatting is applied. If a previous macro cleared cell contents but didn't delete the table row object, it leaves a formatted empty row behind.
Can I undo a VBA macro that deletes rows?
No, actions performed by a VBA macro generally clear the Excel undo history. You cannot use Ctrl+Z to recover rows deleted by VBA, which is why testing on a backup copy is crucial.
How do I remove empty rows without using VBA?
You can highlight your table, press Ctrl+G to open the 'Go To' dialog, click 'Special', select 'Blanks', and then delete the selected rows via the Home tab or right-click menu.
Does WPS Office support Excel VBA macros?
Yes, the Pro version of WPS Office includes full support for VBA macros, allowing you to run and edit your existing Excel scripts seamlessly.




