Excel rows removal, if not bewteen two given dates.

excel , vb , dup Bombay, India
  • 6 years ago

    Hi, i have a excel file named user_data.xls, in this I have a column which holds Date and time in *10/8/08 5:20:29 PM GMT * 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 Sheet1.Activate 'Assume column C contains the dates Application.Range("C1").Select '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

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra