Hi everyone,
I have problem with a code i use, it is attached in the sample file.
Sample.xlsm
What it is supposed to do is check the latest dated data in sheet1, then go to sheet2, copy entire columns with dates only later than in sheet1, loop until end of data in sheet2. Currently it does not work, im not sure which part of the code is wrong.
Sub TheCopier()
Dim i As Long, LastCol As Long, LastDate As Date
Sheets("Sheet1").Activate
LastCol = Cells(10, Columns.Count).End(xlToLeft).Column
LastDate = WorksheetFunction.Max(Range("a10").Resize(, LastCol))
With Sheets("Sheet2")
With .Range("A10", .Cells(1, Columns.Count).End(xlToLeft))
For i = 1 To .Columns.Count
If .Cells(i).Value > LastDate Then
LastCol = LastCol + 1
.Cells(i).EntireColumn.Copy Cells(1, LastCol)
End If
Next i
End With
End With
End Sub
Please help out, thanks.
Bookmarks