+ Reply to Thread
Results 1 to 8 of 8

VBA to delete rows based on date

  1. #1
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    VBA to delete rows based on date

    Hi all

    I have the following code to delete rows based on dates, but the datea I'm using has over 100,000 records and this is taking forever, is there a fasterway to do this than looping through every line?

    Please Login or Register  to view this content.
    I'd thought about using autofilters, but I've heard they can be very unstable...?

    thanks in advance

  2. #2
    Registered User
    Join Date
    10-10-2015
    Location
    Hoboken, Antwerp, Belgium
    MS-Off Ver
    2010
    Posts
    93

    Re: VBA to delete rows based on date

    Hi,

    It's possible with the find command, p.e:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Greetings,

    Cheetahke

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

    Re: VBA to delete rows based on date

    If you change your mind about autofilters.

    Please Login or Register  to view this content.
    I would suggest testing it by highlighting the rows instead of deleting to see how it performs.

  4. #4
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to delete rows based on date

    Hi John

    thanks, but I am having issues with it as I am using UK format dates - dd/mm/yyyy

    Do you know anyway to get around that?

    thanks again

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

    Re: VBA to delete rows based on date

    Does this help? Changes to US, deletes rows, changes back.

    Please Login or Register  to view this content.
    Probably better ways though.

  6. #6
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: VBA to delete rows based on date

    Hi

    still not getting on with that

    VBA really seems to hate UK dates!!

    I'm also changing the line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    as I want to delete anything outside of the start and end dates

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

    Re: VBA to delete rows based on date

    I think xlAnd should still be your operator in that case as well. Hard to tell from this side for me, but when I tested reversing them as I suggested, it worked.

  8. #8
    Registered User
    Join Date
    10-10-2015
    Location
    Hoboken, Antwerp, Belgium
    MS-Off Ver
    2010
    Posts
    93

    Re: VBA to delete rows based on date

    Hi,

    I've changed the code from John a little bit, can you try this? I'm used to work with Belgian dates, same format as UK dates

    Please Login or Register  to view this content.

+ 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 based on date range
    By hommeg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2015, 04:59 PM
  2. How to automatically delete rows in Excel based in day of week and date?
    By pr0no in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2012, 03:22 PM
  3. Delete rows based on date
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-09-2009, 01:44 AM
  4. Delete rows based on date
    By mattbrem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2009, 12:22 PM
  5. Delete Rows based on date range.
    By ge0rge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2009, 10:52 AM
  6. Macro required to delete rows based on date
    By jalalini in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2008, 03:27 AM
  7. Delete rows based on date range entered?
    By fzrdiva in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2006, 08:52 AM

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