Hi there, I am trying to make a code where I will copy the row of date if the date meets the criteria. The data will be pasted onto another sheet in the workbook. However, I have this error which i was not able to solve..
VBA Code:
Private Sub LoggedAss_Click()
Dim lastrow As Long, erow As Long, i As Long
Dim mydate As Date
lastrow = General_Logsheet.Cells(Rows.Count, 1).End(xlUp).Row
General_Logsheet.Range("A1").Select
For i = 2 To lastrow
mydate = Cells(i, 4)
If mydate = Year(Date) Then
erow = Sheet(Year(Date) & "_Logged").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 1), Cells(i, 2), Cells(i, 3), Cells(i, 4)).COpy Destination:=Sheets(Year(Date) & ("_logged")).Cells(erow, 1)
End If
Next i
End Sub