+ Reply to Thread
Results 1 to 3 of 3

Macro delete rows containing specific words

  1. #1
    Forum Contributor
    Join Date
    06-13-2012
    Location
    ND
    MS-Off Ver
    Excel 2010
    Posts
    152

    Macro delete rows containing specific words

    I need a macro to delete any rows that contains: "duplicate", "inactive", "obsolete", "needs approval", or "removed" in column B.

    Any row that contains any of those words should be deleted.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro delete rows containing specific words

    Maybe:

    [code]
    Sub mcrandazz()
    Dim rcell As Range
    On Error Resume Next
    For Each rcell In Range("B2:B" & ActiveSheet.UsedRange.Rows.count)
    If rcell.Value Like "*DUPLICATE*" Then rcell.EntireRow.Delete
    If rcell.Value Like "*INACTIVE*" Then rcell.EntireRow.Delete
    If rcell.Value Like "*OBSOLETE*" Then rcell.EntireRow.Delete
    If rcell.Value Like "*NEEDS APPROVAL*" Then rcell.EntireRow.Delete
    If rcell.Value Like "*REMOVED*" Then rcell.EntireRow.Delete
    Next rcell
    On Error GoTo 0
    End Sub
    [/copy]

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Macro delete rows containing specific words

    My only additional suggestion would be to delete rows from the bottom up as it takes longer if Excel starts to delete from the top. Also I would remove the case-sensitivity:

    Please Login or Register  to view this content.
    abousetta
    Last edited by abousetta; 12-11-2013 at 05:15 PM. Reason: minor code adjustment
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

+ 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. Macro to delete specific rows
    By slade8200 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2013, 04:06 PM
  2. [SOLVED] Macro to delete rows that do not contain certain text - search multiple words
    By CZM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-15-2012, 11:41 AM
  3. Replies: 1
    Last Post: 07-13-2012, 08:17 AM
  4. Simple MACRO to delete words not required in ROWS
    By soni77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2011, 10:58 AM
  5. macro to delete specific rows
    By burgerboy2k6 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2007, 04:58 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