+ Reply to Thread
Results 1 to 9 of 9

Is there a faster way than a loop to delete rows that satisfy a criteria

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Is there a faster way than a loop to delete rows that satisfy a criteria

    Hi everyone,

    I am deleting every sunday from a 5- year dates list.

    My list of date is in column "A".

    Since Sunday = weeday("date") -> 7

    I do the following:

    Please Login or Register  to view this content.
    This works, but it takes a while, do you know another way to delete things within a range that is quicker?

    Thanks for your time,

    -Phil

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    You could turn your screenupdating off.

    Application.screenupdating = false

    YOUR CODE

    Application.screenupdating = true

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    7 for Sunday?
    1 for Sunday to me...
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    Thanks guys.

    I put a timer on my code and here is my results:
    On a total of 1,304 dates it tooks
    1) updatescreen turn on = 01:56
    2) updatescreen turn off = 01:46

    Ps my computer is not very fast, though!

    Sorry
    Jindon: you are right sunday = 1 not 7. let me try your solution.

  5. #5
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    Jindon: your solution took 40 seconds. that is awesome.


    now, I need to understand it.

    1) I get the first part With "a range"
    2) the second line I don't entirely understand it. I have never used EVALUATE
    3) then you cleared any empty cell within the range using specialcells(4).delete

    thanks a lot for your solutions guys
    -Phil

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    40 Sec?

    How many rows do you have?

    I tested with 4000 rows and took only 0.5 sec.

  7. #7
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    only a 1000 rows, let me try that again. I will first kill any other software and repopen excel.

    by the way, I am impress this evaluate method I need to get familiar with it

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    Try add two lines
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Is there a faster way than a loop to delete rows that satisfy a criteria

    that is even faster, Thanks !!

+ 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] More efficient and faster way to delete Rows?
    By nironto in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-07-2013, 05:01 AM
  2. Delete the rows of a specific account if a certain column does not satisfy
    By exlgh91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2013, 04:10 PM
  3. Loop through rows and delete based on criteria
    By yolandaro30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-27-2012, 12:23 PM
  4. Loop to delete rows meeting criteria
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2009, 04:54 PM
  5. How to loop through worksheet and delete rows based on criteria
    By rgrogan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-20-2007, 05:28 PM

Tags for this Thread

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