+ Reply to Thread
Results 1 to 7 of 7

Vba to select rows based on date and Delete

  1. #1
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Vba to select rows based on date and Delete

    Hello,

    I want to delete the rows which are not <=8 days and >=8 days.

    for ex: lets take today's date 29/06/2016. So now select the rows that is not <= 8 days and >8 days from 29/06/2016 on wards.
    and delete the rows who's dates are not <=8 days and >8 days.

    Below is pic.

    date.PNG

    Thank You!

    Regards
    Wither
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Vba to select rows based on date and Delete

    delete the rows who's dates are not <=8 days and >8 days.
    is that means
    to delete rows who's dates are >8 days and <8 days.
    Can you show which one to delete in your example
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: Vba to select rows based on date and Delete

    Hello PCI,

    In the below pic we should delete the rows whose dates are 6/20//2016 as its not < 8 days from today's date 6/30/2016. It is 11 days so delete it.

    Delete the rows were date is 7/15/2016 as its more than 8 day's from 6/30/2016

    resdate.PNG


    Regards
    Wither
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Vba to select rows based on date and Delete

    Why not:
    - prepare a filter => Select column A to E => Data > Filter
    - make the selection
    => in column E header => Date Filters
    => is before 22 / 06 /2016
    => or is after 6/07/2016

    and delete.

  5. #5
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: Vba to select rows based on date and Delete

    Hello,

    If i use filter i will have to specify before and after dates every time (the dates varies) and i get many files every day. So i want to create a macro.

    i tried with the below code but its deleting even the rows that have 6/28/2016 and 7/4/2016. Can u pls help me with the below code and let me know were i am going wrong.

    Please Login or Register  to view this content.

    Thank You!

    Regards
    Wither

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Vba to select rows based on date and Delete

    Several issues:
    1 - When deleting rows, start by the last one and scroll up to avoid confusion for Excel in the index: if deleting cells(10,1) what is the next cells ...?
    or delete all rows in one shot => see macro attached
    2 - .Cells(Rows.Count, 2) is making reference to column 2 where there is no date
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: Vba to select rows based on date and Delete

    Hello PCI,

    sorry for replying you so late,

    and thanks for briefing me were i am going wrong !

    Regards
    Wither

+ 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. VBA to delete rows based on date
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2015, 10:28 AM
  2. Select multiple rows and cells based on a single date
    By UTLee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-16-2013, 11:09 AM
  3. how to select (or delete) rows based on column time
    By sserafini in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-06-2010, 03:01 AM
  4. Delete rows based on date
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-09-2009, 01:44 AM
  5. Delete rows based on date
    By mattbrem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2009, 12:22 PM
  6. Select rows in table based on start and end date
    By packe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2007, 12:18 PM
  7. Select and Delete Rows Based on Various Possibilities in First Cell
    By notdave in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2005, 11:40 AM

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