Results 1 to 2 of 2

Thread: Delete rows if they don't contain multiple specific text
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2019
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Delete rows if they don't contain multiple specific text

    I would like to delete all rows that don't contain multiple specific text in column D. The below code works great for two options but I have a list of twelve words that I would like to add.

    Sub Del_Rows()
    With Range("A1", Range("D" & Rows.Count).End(xlUp))
    .AutoFilter Field:=4, Criteria1:="*apple*", Operator:=xlOr, Criteria2:="orange"
    .EntireRow.Delete
    .AutoFilter
    End With
    End Sub
    Thanks in advance
    Last edited by Mux99; Apr 18th, 2019 at 08:58 AM.

  2. #2
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,789
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Delete rows if they don't contain multiple specific text

    .
    You can first filter the rows that do not have the terms. Look at "autofilter rows array".

    https://heelpbook.altervista.org/201...in-autofilter/

    Code:
    http://WS.UsedRange.AutoFilter Field:=2, Criteria1:=Array("Apples","Peaches","Grapes), Operator:=xlFilterValues




    Then you can delete the visible rows that are left. https://stackoverflow.com/questions/...-rows-in-excel

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •