+ Reply to Thread
Results 1 to 10 of 10

Delete rows with specific values

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Delete rows with specific values

    Any trics to make code below faster/easier/shorter?
    I'm also out of OR statements and need to add more, I don't know how.
    Thanks in advice for any help with this one.

    Please Login or Register  to view this content.
    Last edited by louvaek; 06-13-2019 at 07:42 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Delete rows with specific values

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Delete rows with specific values

    Like this?

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Delete rows with specific values

    Hi louvaek,

    One way to get around the issue with all the or statements (and not having room for more) would be to add the items to a dictionary, and then just using that for a simple check. It may also speed things up slightly since the comparison gets simplified, but I doubt it will make a huge performance difference. I changed your loop because it said " For Lrow2 = Lastrow To Firstrow Step -1" but your variables have a 2 after them so this loop when tested was giving me Lrow2 values of 0


    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Delete rows with specific values

    Another variation is to use a list for values to be deleted
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,104

    Re: Delete rows with specific values

    Hello Louvaek,

    Perhaps using Advanced Filter may be a better option:-


    Please Login or Register  to view this content.
    Using this method, you could place all the serial numbers to be deleted into Column A of a new sheet (named "List"), create a named range("Criteria") for all the numbers in Column A and then convert the list to a table. The table will expand/contract as you add/remove numbers.

    I've attached a sample for you to test with but I've only added eight numbers to the "Criteria" list in this sample. Click on the "RUN" button to see it work.

    I hope that this helps.

    Cheerio,
    vcoolio.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,763

    Re: Delete rows with specific values

    Another way with autofilter
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Delete rows with specific values

    Thank you guys, appreciate all these working solutions !!

    *taking a bow*

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,763

    Re: Delete rows with specific values

    You're welcome & thanks for the feedback

  10. #10
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,104

    Re: Delete rows with specific values

    You're welcome Louvaek. Glad that we were able to assist.
    Thanks for the rep also.

    Cheerio,
    vcoolio.

+ 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 Rows except rows with specific values across multiple uniquely named Worksheets
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2016, 03:04 PM
  2. Delete rows having duplicate values in a specific column
    By kre30a in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2015, 02:37 PM
  3. [SOLVED] Delete rows which contain specific values
    By Blake 7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2015, 08:58 AM
  4. delete specific rows based on values in that row
    By bstinson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2013, 03:46 PM
  5. [SOLVED] Looking for VBA code to delete rows if values in 3 specific columns are the same
    By Priceman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2012, 10:32 AM
  6. Excel 2007 : How to delete specific values from rows?
    By leonlwf in forum Excel General
    Replies: 1
    Last Post: 06-01-2012, 12:03 AM
  7. Delete rows with specific column values
    By koklok in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2008, 01:51 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