![]() |
|
#1
|
|||
|
|||
|
With help from the experts at this forum, I crafted the following macro to search for a specific text string. If the text is found within a table, the row is deleted.
Would you help me further restrict this code to only look in the first row and the last row of all tables? I am certainly okay with running two macros if that is less complicated. Thank you in advance for considering my request for help. Code:
Sub DeleteRowIf()
Application.ScreenUpdating = False
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
MyRange.Rows(1).Delete
End If
Wend
End With
Application.ScreenUpdating = True
Application.ScreenRefresh
MsgBox "Done!", vbInformation
End Sub
|
| Tags |
| delete table rows, first row last row, specified text string |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Delete blank table rows in merged document and split document in docx and pdf based on excel rows
|
Alex1s85 | Word VBA | 5 | 05-22-2021 12:05 PM |
Delete blank rows between the two rows that contain data
|
beginner | Excel Programming | 5 | 12-26-2014 12:29 AM |
Delete All empty Rows - Print - Undo all Rows deleted
|
Bathroth | Word VBA | 1 | 10-01-2014 01:40 PM |
| Find and Delete Rows | damaniam | Word VBA | 1 | 03-11-2014 06:54 AM |
Delete all rows but the last.
|
elky1967 | Word VBA | 14 | 09-21-2012 05:27 AM |