+ Reply to Thread
Results 1 to 9 of 9

Locate Specific Text and Delete the Entire Row

Hybrid View

  1. #1
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,786

    Re: Locate Specific Text and Delete the Entire Row

    Don't know how much data (number of rows) you have in the file as I assume the upload is a small sample. If so I think I would start getting rid of duplicates and rows that contains "60-", "2200" and so fort in order to reduce the number of rows to check for blank values in column M and V.

    So adding a few bits and pieces to jindons's code you could try this:

    Sub test()
        Dim a, rng As Range
        Dim mRng As Range
        Dim vRng As Range
    
       Application.ScreenUpdating = False
        
        a = Array("*22000*", "*22005*", "*22025*", "60-*")
        Rows(1).Insert: [v1].Value = "zzz"
        With [a2].CurrentRegion
            With .Offset(, .Columns.Count + 2).Cells(1)
                .Value = "zzz"
                .Offset(1).Resize(UBound(a) + 1).Value = _
                Application.Transpose(a)
                Set rng = .CurrentRegion
            End With
            .AdvancedFilter 1, rng
            .Offset(1).EntireRow.Delete
            .Parent.ShowAllData: rng.Clear
        End With
        
        [M1].Value = "aaa"
        
        ActiveSheet.UsedRange.RemoveDuplicates Columns:=22, Header:=xlYes
        
       Set mRang = Range("M2:M" & Range("A" & Rows.Count).End(xlUp).Row)
       Set wRang = Range("W2:W" & Range("A" & Rows.Count).End(xlUp).Row)
       
       ActiveSheet.UsedRange.AutoFilter Field:=13, Criteria1:="="
    
    On Error Resume Next
    
    mRang.SpecialCells(xlCellTypeVisible).Value = "No Descripion"
    
    ActiveSheet.UsedRange.AutoFilter
    
    On Error Resume Next
    
    ActiveSheet.UsedRange.AutoFilter Field:=23, Criteria1:="="
    
    wRang.SpecialCells(xlCellTypeVisible).Value = "Delete"
    
    ActiveSheet.AutoFilterMode = False
    
    Rows("1:1").Delete Shift:=xlUp
    
    Application.ScreenUpdating = True
    
    ActiveSheet.UsedRange.Columns.AutoFit
        
    End Sub
    Alf

  2. #2
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Locate Specific Text and Delete the Entire Row

    This worked great! Thank you very much. Wonderful macro.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Delete entire row for specific words
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-01-2015, 07:43 PM
  2. [SOLVED] How to locate specific text within a cell, starting from the right
    By SimplySA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2014, 04:27 AM
  3. [SOLVED] Locate column with specific title and delete rows if predefined set of text is found
    By johnny_tc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 01:57 PM
  4. [SOLVED] Macro: Locate specific text within supplied range
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2012, 01:03 PM
  5. Locate a reference in a table based on specific words on a text
    By zetavares83 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2012, 06:17 PM
  6. Locate row above cell with specific text, and apply formatting?
    By HelenW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2009, 11:09 AM
  7. Locate and delete specific cells
    By David Smith in forum Excel General
    Replies: 1
    Last Post: 01-19-2005, 01:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1