+ Reply to Thread
Results 1 to 4 of 4

Search for Specific Text in a column & Delete Rows

Hybrid View

area51plustax Search for Specific Text in a... 07-19-2017, 01:26 AM
JBeaucaire Re: Search for Specific Text... 07-19-2017, 01:33 AM
area51plustax Re: Search for Specific Text... 07-19-2017, 01:33 AM
JBeaucaire Re: Search for Specific Text... 07-19-2017, 01:41 AM
  1. #1
    Registered User
    Join Date
    08-05-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    22

    Question Search for Specific Text in a column & Delete Rows

    Hello,

    I am looking for a macro to search specific column (Lets Say Column B), search for a word "Demo" within data at every cell in that column and delete all those rows consist of it

    Is it possible?

    Thanks

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search for Specific Text in a column & Delete Rows

    This would do as you've described. It is not CASE specific so it will find DEMO, demo, DEmo, and any other variation. It also only deletes once at the end, so should be quicker than a row by row deletion.
    Sub DeleteDEMOrows()
    Dim delRNG As Range, vFIND As Range, vFIRST As Range
    
    On Error Resume Next
    Set vFIND = Range("B:B").Find(What:="demo", LookAt:=xlPart, MatchCase:=False, SearchFormat:=False)
    On Error GoTo 0
    
    If Not vFIND Is Nothing Then
        Set vFIRST = vFIND
        Set delRNG = vFIND
        Do
            Set delRNG = Union(delRNG, vFIND)
            Set vFIND = Cells.FindNext(After:=vFIND)
        Loop Until vFIND.Address = vFIRST.Address
        
        delRNG.EntireRow.Delete xlShiftUp
    End If
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-05-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    22

    Re: Search for Specific Text in a column & Delete Rows

    Thank you very much

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search for Specific Text in a column & Delete Rows

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Delete Rows with specific text in specific column
    By love2waltz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2015, 10:16 AM
  2. Search rows to find specific text and move to a different column ?
    By Udaipur99 in forum Excel - New Users/Basics
    Replies: 19
    Last Post: 03-19-2014, 01:11 PM
  3. [SOLVED] Need to search for a specific string in Column A and delete values within the same row
    By hgeo24 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-27-2014, 04:56 PM
  4. Loop to search specific names in column and delete other rows
    By EJ_2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 01:28 PM
  5. Delete rows with specific text in column
    By danieldaniel1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2013, 12:47 PM
  6. [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
  7. Replies: 5
    Last Post: 08-16-2006, 02:05 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