Excel rows removal, if not bewteen two given dates. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Excel rows removal, if not bewteen two given dates.

johnkjjohnkj Posts: 3Member
i have a excel file named user_data.xls, in this I have a column which holds Date and time in [b]10/8/08 5:20:29 PM GMT[/b] format. Now I want to keep the data between two specific dates and remove remaining all rows from excel, how can i do it through a script.

Below is the script I came up to, could someone please help on how can i proceed from here onwards...

Dim dStartDate As Date
Dim dEndDate As Date

'Collect Start & End Dates
dStartDate = 10/1/11 5:20:29 PM GMT
dEndDate = 10/30/11 5:20:29 PM GMT

'Find Dates Between Start Date & End Date

'Assume column C contains the dates

'Look at every row in column C until it finds an empty cell.
Do Until ActiveCell.Value = vbNullString

'Verify that the date is between the Start Date & End Date
If ActiveCell.Value > dStartDate And ActiveCell.Value < dEndDate Then
Sign In or Register to comment.