I'm trying to make a function that copies the information from one sheet to another but I'm struggling with the paste as values function. Do you know why it is not working?
Sub Copy_Data()
Dim Src As Worksheet, Dst As Worksheet
Dim LastRow As Long, r As Range
Dim CopyRange As Range
'Change these to the correct sheet names
Set Src = Sheets("Sheet1")
Set Dst = Sheets("Sheet2")
LastRow = Src.Cells(Cells.Rows.Count, "A").End(xlUp).Row
For Each r In Src.Range("A2:A" & LastRow)
If (Month(r.Value) = "2" And Year(r.Value) = "1902") Then
If CopyRange Is Nothing Then
Set CopyRange = r.EntireRow
Else
Set CopyRange = Union(CopyRange, r.EntireRow)
End If
End If
Next r
If Not CopyRange Is Nothing Then
CopyRange.Copy Dst.Range("A1").PasteSpecial(xlPasteValues)
End If
End Sub