![]() |
#2
|
||||
|
||||
![]()
This shows you the extra test to work out if it is a first or last row.
Code:
Sub DeleteRowIf() Dim MyRange As Range Set MyRange = ActiveDocument.Range With MyRange.Find .ClearFormatting .Text = "TEXT TO FIND" .MatchCase = True .Forward = True .Wrap = wdFindStop .Format = False While .Execute If MyRange.Information(wdWithInTable) Then If MyRange.Rows.First.Range = MyRange.Tables(1).Rows.First.Range Or MyRange.Rows.First.Range = MyRange.Tables(1).Rows.Last.Range Then MyRange.Rows(1).Delete End If End If Wend End With MsgBox "Done!", vbInformation End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Tags |
delete table rows, first row last row, specified text string |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Alex1s85 | Word VBA | 5 | 05-22-2021 12:05 PM |
![]() |
beginner | Excel Programming | 5 | 12-26-2014 12:29 AM |
![]() |
Bathroth | Word VBA | 1 | 10-01-2014 01:40 PM |
Find and Delete Rows | damaniam | Word VBA | 1 | 03-11-2014 06:54 AM |
![]() |
elky1967 | Word VBA | 14 | 09-21-2012 05:27 AM |