+ Reply to Thread
Results 1 to 5 of 5

Macro to Retain dates in a range

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Macro to Retain dates in a range

    i have the start date in D1 and the End Date in C1

    I need a macro to retain all the dates in Col A the fall between the start date and end date and to delete the rows containing dates that fall outside this range


    I have attached sample data


    it would be appreciated if someone could kindly assist me
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,239

    Re: Macro to Retain dates in a range

    This can be done without a macro.
    See the attachment. I used Advanced Filter.
    The filter criterion can be specified in two different ways. Either the range C1:C3 or D1:D2. After filtering, select the visible rows and delete them.

    Artik
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain dates in a range

    Thanks Artik. The advanced filter works well on your workbook

    However, When I deteted the visible row, the hidden rows are also deleted

    Please advise how to prevent this

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,239

    Re: Macro to Retain dates in a range

    I don't think so. You probably didn't clear the Advanced Filter after removing the visible rows. Use the "Clear" icon near to the "Filter" icon.

    Artik

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain dates in a range

    Thanks or the reply. I did ascertain before you replied that I had to clear the filter

    once again thanks for all your help

+ 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] MACRO to retain a copy of a certain range to different sheet collectively
    By archvanarl in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-22-2021, 08:46 AM
  2. [SOLVED] Copy range to a new workbook & retain range names
    By Aland2929 in forum Excel General
    Replies: 2
    Last Post: 09-28-2017, 02:48 AM
  3. Count number of dates values in each cell and retain larger value only
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2016, 11:07 PM
  4. VBA Dynamic Page Break to retain a range when printing
    By drewmey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2015, 10:08 AM
  5. how to retain the colour of selected Dates in this calendar Form
    By prabhuduraraj09 in forum Access Tables & Databases
    Replies: 4
    Last Post: 07-06-2015, 10:40 AM
  6. [SOLVED] Macro DtRNG as Range, Dt as Range, Multiple Criteria or dates
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 03-18-2013, 03:46 PM
  7. Retain Max value of Range in another Cell
    By excelbaba in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-06-2010, 11:32 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