+ Reply to Thread
Results 1 to 10 of 10

Filter/Delete Rows

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Filter/Delete Rows

    Hello!

    I have a large data file that is exported from another database that I need to filter and delete rows that don't match certain criteria. This worksheet has between 40,000-80,000 rows and after it's cleaned up sits at around 50% of its previous size. I have tried writing a macro to delete what I don't need, but it does it row by row, I was wondering if I could get help automating this!

    What I'm looking for it to do:

    1. Delete any row that doesn't have "CHECKED IN" or "CHECKED OUT" in Column O
    2. Delete any row where the value in Column AI is less than 69
    3. Delete any row where Column AH doesn't contain "CKOT" or "CKIN"

    Thanks!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Filter/Delete Rows

    So you do not want a macro does the deletion row by row checking for each condition?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Filter/Delete Rows

    Filter on each criteria, then select visible cells only for deletion using

    Please Login or Register  to view this content.
    HTH

    GJCase
    Last edited by arlu1201; 10-12-2012 at 02:29 PM.

  4. #4
    Registered User
    Join Date
    08-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Filter/Delete Rows

    Going row by row for ~80,000 lines would take hours, I'm looking for an easy way to sort/filter the data by each condition then delete the data that doesn't fit the criteria, then move onto the next condition. I'm just having trouble with setting up the macro to do this.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Filter/Delete Rows

    Try his code
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Filter/Delete Rows

    @gjcase
    Is there a way to do the exact opposite and filter in a way to only show the items that match all my criteria and delete all hidden rows?
    Last edited by Cutter; 10-17-2012 at 07:58 PM. Reason: Removed whole post quote

  7. #7
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Filter/Delete Rows

    This will filter for all cells in range A1:B8 which do not contain the word "checked" in the first column of the range:

    Please Login or Register  to view this content.
    ---GJC

  8. #8
    Registered User
    Join Date
    08-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Filter/Delete Rows

    I ended up just doing this:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Filter/Delete Rows

    Did you not try the code i posted? It performs all the deletions you require as per the conditions.

  10. #10
    Registered User
    Join Date
    08-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Filter/Delete Rows

    The code you posted filters based on the first criteria, deletes the items that don't meet that and doesn't check the rest of the criteria because it doesnt unfilter the other data. It also takes longer for your code to run versus the one I posted above.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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