+ Reply to Thread
Results 1 to 10 of 10

Delete Rows greater than current date

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Delete Rows greater than current date

    Hi,

    I have a report in that in B Column dates are listed in sorting order, now i need a coding like if i run the macro today, it should retain from back dated to current date and delete all the future details.

    (For Example: If the report is being created on Monday, June 3rd, then any details due on June 3rd or prior, would be entered in this field. Delete all the rows from June 4th)

    Sheet has been attached for your easy reference, please help on this...
    Attached Files Attached Files
    Last edited by kesavanprabhu; 06-13-2013 at 10:58 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete Rows greater than current date

    Hi, kesavanprabhu,

    maybe this is what you are looking for (please try on a sample):
    Please Login or Register  to view this content.
    I would reconsider the aspect of deleting data and maybe just hide the rows instead.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Delete Rows greater than current date

    Hi Holger,

    Thanks for your coding,it worked only 50%. In your coding if today's date is not available it prompts a msgbox, actually it is not required.

    below example will give you idea on my expectation...

    Example: I have a data from May1st to may29th and again data continues from June 5th to June20th... (some times i might get the current date or may not but my coding should consider the data till current date) now my requirement is I need to keep the data till current date ie., in this example i will be retaining data till 29th and i need to deletethe data from june 5th.

    If i am not clear pls let me know, i will try explain in better way.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete Rows greater than current date

    Hi, kesavanprabhu,

    and what about this code?
    Please Login or Register  to view this content.
    Thinking about it this code may lead to an infinite loop if today´s date is less than the earliest date in the list.

    This code should take care of that problem:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 05-31-2013 at 05:34 PM.

  5. #5
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Delete Rows greater than current date

    Holger thank you very much its working.....

  6. #6
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Delete Rows greater than current date

    Hi Holger,

    When i executed the coding there was a problem in getting the output. For Example in B column 8,9,10th rows as today's date(or previous date) and 11th row as tomorrow's date and so on.

    By executing the code actually i am looking the result should come like till 10th row the data should retain and from 11th row all the data's should be deleted, but now when executing the code it retains till 8th row and deleting the datas from 9th row which is wrong.

    Can you check and give solution for this I have attached excel sheet for your reference.
    Attached Files Attached Files

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete Rows greater than current date

    Hi, kesavanprabhu,

    not really great a problem. Based on the last coding:
    Please Login or Register  to view this content.
    Or use
    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Delete Rows greater than current date

    Thanks Holger.... Can you explain me this coding so that i can understand and work on this...

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Delete Rows greater than current date

    Hi, kesavanprabhu,

    me and commenting - not really one of my favourites.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Ciaom
    Holger

  10. #10
    Registered User
    Join Date
    05-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Delete Rows greater than current date

    Thank you very much Holger....

+ 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