View Single Post
 
Old 05-25-2022, 04:21 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It does, if 'Info:' the only thing in the cell. You asked for a macro that works as follows
Quote:
Originally Posted by Mattc1978 View Post
What I'd really want is if the cell only contains "info:" then delete the/ remove the cell
I suspect you still have cells containing rather more than that (e.g. 'header' content before 'Info:', spaces, paragraph breaks, etc. after 'Info:'). Try the following macro, which combines both the text cleanup and row deletion - accommodating that 'extra' content:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .Text = "[\[\]\*“”""""]"
    .MatchWildcards = True
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    .Text = "Info[: ^s.^t^13]{1,}"
    .Replacement.Text = ""
    .Wrap = wdFindStop
  End With
  Do While .Find.Execute
    If .Information(wdWithInTable) = True Then
      If .End = .Cells(1).Range.End - 1 Then .Rows.Delete
    End If
    .Collapse wdCollapseEnd
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote