+ Reply to Thread
Results 1 to 7 of 7

VBA that deletes entire rows if value is NOT found in part

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    VBA that deletes entire rows if value is NOT found in part

    Hello All,
    I wish to delete rows that do NOT contain the word "Total" in column D. Thus in my example, the VBA code should manipulate the first spreadsheet (1. Delete rows if value NOT found), so that it ends up looking like the second spreadsheet (2. Delete rows if value NOT found result). Note that the word "Total" is only part of the text in those cells where it appears.

    Thanking you in advance for your help,
    Andrewstupendo

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: VBA that deletes entire rows if value is NOT found in part

    Here's one way:
    Please Login or Register  to view this content.
    BSB

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Another way …


    As a beginner starter :

    PHP Code: 
    Sub Demo1()
        
    With Sheet1.Range("D1:D" Sheet1.UsedRange.Rows.Count)
            .
    AutoFilter 1"<>*Total*"
            
    .Offset(1).EntireRow.Delete
            
    .AutoFilter
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  4. #4
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    Re: VBA that deletes entire rows if value is NOT found in part

    Dear BSB,
    I tried your first macro and it works beautifully. Simple yet elegant code - and effective!

    Thanks so much,
    Andrewstupendo

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA that deletes entire rows if value is NOT found in part


    Thanks for the rep' !

  6. #6
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    Re: VBA that deletes entire rows if value is NOT found in part

    Dear BSB,
    Not sure if you received my previous reply. Here it is quoted in full:
    "Dear BSB,
    I tried your first macro and it works beautifully. Simple yet elegant code - and effective!

    Thanks so much,
    Andrewstupendo"

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: VBA that deletes entire rows if value is NOT found in part

    Hi Andrewstupendo,

    Many thanks for the feedback. Glad I could help.

    BSB

+ 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] need to run the entire list then post final result found or not found after.
    By 0o0o0 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-06-2018, 01:00 PM
  2. Found?, then delete entire rows. Not found end sub
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2018, 01:56 PM
  3. MACRO or FUNCTION that deletes entire rows, if containing specific words.
    By Allerdrengen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2017, 07:51 AM
  4. Replies: 3
    Last Post: 10-20-2014, 01:13 PM
  5. [SOLVED] VBA that looks up a string (or part of) value and deletes the cell
    By gaia in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-19-2013, 05:33 AM
  6. Looking up arrays and returning entire rows if match is found
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2009, 06:18 AM
  7. Useful code that deletes entire rows based on formatting
    By Ralfie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2007, 01:02 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