+ Reply to Thread
Results 1 to 7 of 7

Need better and more efficient code deleting unwanted rows.

  1. #1
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    212

    Need better and more efficient code deleting unwanted rows.

    I have a table with apr 400K lines:
    Column C for Ranking: R1 R2 R3 etc
    Column D for Emails: lastname.firstname@mail.com

    I read it is best to use filter then loop but it is not working for me.
    I am trying to keep All R1 with the exception to Emails that has a period.
    Looks like ones not needed is working and get deleted but then reappear.
    What am I missing?

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need better and more efficient code deleting unwanted rows.

    You are quite correct, you certainly don't want to use a loop. Autofilter is the way.

    Please upload the workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.


    To upload a file click the Go Advanced button at the foot of your post, look underneath the post area for the Manage Attachments section and take it from there.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Arrow Re: Need better and more efficient code deleting unwanted rows.


    Hi,

    as the classic Sort & Clear method - see this thread - could be faster than the Filter & Delete method,
    in particular with the more non contiguous rows to delete …

  4. #4
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: Need better and more efficient code deleting unwanted rows.

    With this example. Only line 3 should remains because C contain R1 and D contain a period.
    Line 8 should not be use because a period is not present.
    Attached Images Attached Images

  5. #5
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: Need better and more efficient code deleting unwanted rows.

    I like that short and simple.
    Clear and sort rather then delete.
    I will try it out.

    Quote Originally Posted by Marc L View Post

    Hi,

    as the classic Sort & Clear method - see this thread - could be faster than the Filter & Delete method,
    in particular with the more non contiguous rows to delete …

  6. #6
    Forum Contributor
    Join Date
    09-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    212

    Re: Need better and more efficient code deleting unwanted rows.

    Though it is short and look simple. I tried to understand the code but not enough to modify or test to make it work for me
    Quote Originally Posted by Marc L View Post

    Hi,

    as the classic Sort & Clear method - see this thread - could be faster than the Filter & Delete method,
    in particular with the more non contiguous rows to delete …

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

    Arrow Re: Need better and more efficient code deleting unwanted rows.


    So attach at least a workbook in order some helper can give it a try : just follow the top page yellow banner …

+ 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. Efficient VBA code for conditionally deleting rows in big excel sheet
    By akash27 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-05-2017, 01:43 AM
  2. [SOLVED] Deleting Unwanted rows
    By Isara-NJ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2017, 02:47 PM
  3. [SOLVED] Filtering and deleting unwanted rows
    By joshag in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2014, 01:59 PM
  4. [SOLVED] Deleting rows with unwanted data
    By gpowell in forum Excel General
    Replies: 2
    Last Post: 12-06-2013, 05:25 PM
  5. Deleting Unwanted Rows
    By Covenite in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2012, 12:25 PM
  6. Deleting unwanted rows <10
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-25-2009, 11:21 AM
  7. Deleting unwanted rows
    By kevinho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2007, 05:25 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