Hi there,
I attach the file I'm working with. It contains two columns with dates and I want to make them containing exactly the same values. For example, A22 = 01/02/2005 while there is no such date in column B. Hence, I want to delete this so 02/02/2005 comes up and it is equal to cell B22. Then it continues and we have a cell in column A with the date 14/03/2005 but it corresponds with 11/03/2005 on the same row in column B, therefore the cell in column B must be deleted until the two get equal and so on. I wrote the following code:
and it runs through the observations up to the beginning of 2006 when it can't go any further. I would greatly appreciate any suggestions on your side. Thank you! Dates.xlsx![]()
Sub Whatever() For i = 1 To 2246 If Worksheets("Dates").Cells(1 + i, 1) < Worksheets("Dates").Cells(1 + i, 2) Then Worksheets("Dates").Cells(1 + i, 1).Delete Shift:=xlUp Do Until Worksheets("Dates").Cells(1 + i, 1) >= Worksheets("Dates").Cells(1 + i, 2) Loop ElseIf Worksheets("Dates").Cells(1 + i, 1) > Worksheets("Dates").Cells(1 + i, 2) Then Do Until Worksheets("Dates").Cells(1 + i, 1) = Worksheets("Dates").Cells(1 + i, 2) Worksheets("Dates").Cells(1 + i, 2).Delete Shift:=xlUp Loop End If Next i End Sub
Bookmarks