View Single Post
 
Old 03-18-2017, 11:56 AM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

The macro will do what you are seeking. Remove the word Not from the
macro line as indicated, then run the code.

The two Input Boxes that appear give you much more range to do what you want
without having to constantly go into the macro and change the code for the range or
search term you are needing.

Code:
Option Explicit

Sub DeleteRowNoInclude()
'Update20140618
Dim xRow As Range
Dim rng As Range
Dim WorkRng As Range
Dim xStr As String
Dim i As Integer
On Error Resume Next
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", WorkRng.Address, Type:=8)
xStr = Application.InputBox("Text", Type:=2)
Application.ScreenUpdating = False
For i = WorkRng.Rows.Count To 1 Step -1
    Set xRow = WorkRng.Rows(i)
    Set rng = xRow.Find(xStr, LookIn:=xlValues)
        
    If rng Is Nothing Then   '<-- I removed Not from the line. Try it now.
       xRow.Delete
    End If
Next
Application.ScreenUpdating = True
End Sub