Delete Rows not <> to

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all

I hope you can help me on this please

I want to change this code so that it delete all row NOT equal to "INS" instead of deleting "INS"

Any ideas please

Code:
arrWords = Array("INS")
     xlCalc = Application.Calculation
     Set rng = Range("c1:c2000")
     For rw = rng.Rows(rng.Rows.Count).Row To rng.Rows(1).Row Step -1
             For j = 0 To UBound(arrWords)
                     If InStr(1, rng(rw, 1), arrWords(j), vbTextCompare) Then
                             bDel = True
                             rng.Parent.Rows(rw).EntireRow.Clear
                             Exit For
                     End If
             Next
     Next
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this:
Code:
Sub Filter_Me_Please()
'Modified  8/16/2018  4:52:39 AM  EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Dim c As Long
Dim s As Variant
c = "3" ' Column Number Modify this to your need
s = "INS" 'Saerch Value Modify to your need
Lastrow = Cells(Rows.Count, c).End(xlUp).Row
With ActiveSheet.Cells(1, c).Resize(Lastrow)
    .AutoFilter 1, "<>" & s
    counter = .Columns(c).SpecialCells(xlCellTypeVisible).Count
    If counter > 1 Then
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    Else
        MsgBox "No values found"
    End If
    .AutoFilter
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Maybe this

Code:
For j = 0 To UBound(arrWords)
                     If InStr(1, Rng(rw, 1), arrWords(j), vbTextCompare)[color=red] = 0[/color] Then
                             bDel = True
                             Rng.Parent.Rows(rw).delete
                             Exit For
                     End If
             Next
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top