![]() |
#4
|
||||
|
||||
![]()
Perhaps:
Code:
Sub Demo() Application.ScreenUpdating = False Dim RngFnd As Range, RngDel As Range With Selection.Tables(1) Set RngFnd = .Range: Set RngDel = .Range RngDel.Collapse wdCollapseStart With .Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Highlight = True .Format = True .MatchWildcards = False End With Do While .Find.Execute If .InRange(RngFnd) = False Then Exit Do If .Cells(1).RowIndex > RngDel.Cells(1).RowIndex Then RngDel.End = .Tables(1).Cell(.Cells(1).RowIndex - 1, 1).Range.End RngDel.Rows.Delete End If RngDel.Start = .Tables(1).Rows(.Cells(1).RowIndex).Range.End + 1 .End = .Cells(1).Range.End If .Information(wdAtEndOfRowMarker) = True Then .End = .End + 1 .Collapse wdCollapseEnd Loop End With If RngDel.Information(wdWithInTable) = True Then If RngDel.Cells(1).RowIndex <= .Rows.Count Then RngDel.End = .Range.End RngDel.Rows.Delete End If End If End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
kippiebla | Excel Programming | 4 | 05-10-2020 12:18 AM |
![]() |
Btop | Word VBA | 7 | 02-13-2018 05:36 PM |
![]() |
cltay87 | Word VBA | 4 | 02-27-2017 04:23 AM |
![]() |
beginner | Word | 2 | 01-05-2015 05:47 AM |
![]() |
Elan05 | Word VBA | 23 | 09-11-2014 12:47 PM |