+ Reply to Thread
Results 1 to 6 of 6

Macro to delete rows that do not meet one of many criteria in referenced cell

  1. #1
    Registered User
    Join Date
    07-09-2013
    Location
    Louisiana
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro to delete rows that do not meet one of many criteria in referenced cell

    I'm having trouble getting a code to work. I've seen several post for "if they meet criteria," but not too many to address what I need. There are far too many that I do not want and a manageable amount that I want to keep for any given report. Here is what I have, hopefully someone can correct it or offer something better. Thanks in advance.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Ontario Canada
    MS-Off Ver
    Excel 2010
    Posts
    124

    Re: Macro to delete rows that do not meet one of many criteria in referenced cell

    Most of the time, for multiple <> statements, you will want ANDs instead of ORs.

    You could also use AutoFilte which would be faster.
    But Since you already have your loop, try the AND thing first

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Macro to delete rows that do not meet one of many criteria in referenced cell

    Hi blaque,

    Here's one way to do it :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Macro to delete rows that do not meet one of many criteria in referenced cell

    Oups,
    I believe I got the code wrong. If you want to keep the rows matching you criteria, this should work better :

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-09-2013
    Location
    Louisiana
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to delete rows that do not meet one of many criteria in referenced cell

    Guys thanks for your help. My loop must have a flaw because even with the "AND" it would leave some of the unwanted ticket types. I believe this is due to it skipping one once a row is deleted. GC Excel your solution worked perfect. Thanks a lot your both of your help!

  6. #6
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Ontario Canada
    MS-Off Ver
    Excel 2010
    Posts
    124

    Re: Macro to delete rows that do not meet one of many criteria in referenced cell

    Hey Blaque,
    Glad you got it to work.

    As a side note, yes you are right.
    The reason the ANDs didnt work is beacsue if you are deleting rows, you have to go from bottom up instead of top down using step -1 like GC did.

+ 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 rows if criteria is referenced in other sheets?
    By jsabo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 02:08 PM
  2. Macro or script to delete rows that meet certain criteria
    By stlawr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2011, 11:36 AM
  3. How to delete all rows with the same name as a row that meet a certain criteria.
    By shaihulud in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-19-2010, 04:50 PM
  4. [SOLVED] Formula/Macro to delete rows that do not meet criteria from a list?
    By S Davis in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-12-2006, 02:45 PM
  5. Macro, delete rows that meet criteria
    By Scott Wagner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-22-2005, 08:10 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