View Single Post
 
Old 01-17-2018, 04:01 PM
puff puff is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You don't need an OR test for what you've described; you need a LIKE test:
Code:
Sub DeleteLinesStartWith()
Dim i As Long
With ActiveDocument
  For i = .Paragraphs.Count To 1 Step -1
    With .Paragraphs(i).Range
      If LCase(Trim(.Words.First.Text)) Like "[!.•]" Then .Delete
    End With
  Next i
End With
End Sub
I tried your code, and it doesn't work on empty lines start with "letter." like "A." although I have changed it to Like "[.1.2.3.4.A.B.C.D.©.!.•]. I changed it because I want to keep the original real empty lines--without anything in the front.

And also, I want to delete empty lines start with letters, like "B". In that case then how could VBA tell the difference between "A." and "A" if you use Like?
Reply With Quote