Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 01-02-2018, 10:24 PM
gmayor's Avatar
gmayor gmayor is offline Delete all empty rows in all tables Windows 10 Delete all empty rows in all tables Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following shouldn't change the format of the table, but if it does, post a document with the errant table. The macro will not work with vertically merged cells

Code:
Sub DeleteEmptyRows()
'Graham Mayor - http://www.gmayor.com - Last updated - 03 Jan 2018
Dim oTable As Table
Dim iRow As Integer
Dim iCol As Integer
    Set oTable = Selection.Tables(1)
    If Selection.Information(wdWithInTable) Then
        For iRow = oTable.Rows.Count To 1 Step -1
            iCol = oTable.Rows(iRow).Cells.Count
            If Len(oTable.Rows(iRow).Range) = (iCol * 2) + 2 Then
                oTable.Rows(iRow).Delete
            End If
        Next iRow
    Else
        MsgBox "Selection is not in a table"
    End If
lbl_Exit:
    Set oTable = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete all empty rows in all tables Delete Empty Table Rows cltay87 Word VBA 4 02-27-2017 04:23 AM
Delete all empty rows in all tables Macro to delete all empty rows from all tables braddgood Word VBA 15 10-02-2015 01:54 PM
Delete all empty rows in all tables Delete blank rows between the two rows that contain data beginner Excel Programming 5 12-26-2014 12:29 AM
Delete all empty rows in all tables Delete All empty Rows - Print - Undo all Rows deleted Bathroth Word VBA 1 10-01-2014 01:40 PM
Delete all empty rows in all tables Macro to delete rows with all empty cells ubns Excel Programming 2 08-14-2012 02:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft