FILTER OR DELETE ROWS CONTAINING WORDS STARTING AND ENDING WITH SPECIFIC TEXT USING VBA

turkanet

New Member
Joined
Aug 20, 2017
Messages
38
Office Version
  1. 2021
Platform
  1. Windows
Dear Freinds,
I need to filter or delete rows in A:N which contain text in N:N starts with "DOV" and ends with "Z" (like DOVTINZ, DOVZ, DOVEZ, etc). If cell is "MARY DOVZ EAGLE", row will be deleted.
Thank you
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Please try the following on a copy of your workbook. Assumes your headers are are on row 1 and that your data starts in row 2. Change the sheet name to suit. This macro deletes the rows.

VBA Code:
Option Explicit
Sub DovZ()
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")   '<-- *** Change name of sheet to suit ****
    If ws.AutoFilterMode Then ws.AutoFilter.ShowAllData
    With ws.Range("A1").CurrentRegion
        .AutoFilter 14, "*DOV*Z*"
        If .SpecialCells(xlCellTypeVisible).Address <> .Rows(1).Address Then
            .Offset(1).EntireRow.Delete
        End If
        .AutoFilter
    End With
End Sub
 
Upvote 0
This is another option ...
VBA Code:
Sub test()

With Range("N1", Range("N" & Rows.Count).End(3))
    .Value = Evaluate(Replace("iferror(if(search(""DOV*Z"",@)>0,""#N/A""),@)", "@", .Address))
    On Error Resume Next
        .SpecialCells(2, xlErrors).EntireRow.Delete
    On Error GoTo 0
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,262
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

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