Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-10-2016, 08:57 PM
gmayor's Avatar
gmayor gmayor is offline Word Macro to delete table row and table header Windows 10 Word Macro to delete table row and table header Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

Based on that information
Code:
Sub RemoveZeroValues()
Dim oTable As Table
Dim oCell As Range
Dim lngCount As Long
    If Not Selection.Information(wdWithInTable) Then
        MsgBox "Put the cursor in the table and run the macro again"
        GoTo lbl_Exit
    End If
    Set oTable = Selection.Tables(1)
    For lngCount = oTable.Rows.Count To 2 Step -1
        Set oCell = oTable.Rows(lngCount).Cells(2).Range
        oCell.End = oCell.End - 1
        If val(oCell.Text) = 0 Then oTable.Rows(lngCount).Delete
    Next lngCount
lbl_Exit:
    Set oTable = Nothing
    Set oCell = 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
 

Tags
table headers, vba macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Macro to delete table row and table header Repeat header of table within another table Dart82 Word Tables 3 04-11-2016 04:15 AM
Word Macro to delete table row and table header How to repeat table header of table within table CTNAM Word Tables 1 04-11-2016 04:14 AM
Delete table lines/Condense table frustrated teacher Word VBA 3 12-14-2015 02:03 AM
Macro Needed to delete Unwanted paragraphs within a table. frustrated teacher Word VBA 0 06-05-2015 12:47 PM
Word Macro to delete table row and table header Unable to delete row below table header clarence Word 2 11-23-2014 02:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:21 PM.


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