I am trying to write a code in sheet1 that would add recent date according to the dates in sheet2.
Sheet1 Sheet2
A A
50 01/02/2019 76 01/02/2019
51 01/03/2019 77 01/03/2019
52 01/04/2019 78 01/04/2019
79 01/05/2019
80 01/06/2019
I thought about copying the whole column and pasting it but it will be unprofessional and the data can be thousands of rows.
Instead how do I check the recent dates in sheet2 (ColumnA) that are not in the sheet1 and copy them?
This is my code so far
Sub Addrecentmonth()
Dim M1 As Worksheet
Dim FinalRowM1 As Long
Dim FinalRowPM As Long
Dim ProbabilityModel As Worksheet
Set M1 = ActiveWorkbook.Worksheets("M1")
Set PM = ActiveWorkbook.Worksheets("ProbabilityModel")
FinalRowM1 = M1.Range("A" & M1.Rows.Count).End(xlUp).Row
FinalRowPM = PM.Range("A" & M1.Rows.Count).End(xlUp).Row
If PM.Range("A" & FinalRowPM).Value <> M1.Range("A" & FinalRowM1).Value Then
M1.Range("A" & FinalRowM1).Select
PM.Cells(Rows.Count, "A").End(xlUp).Offset(1). _
PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=True
Application.CutCopyMode = False
End If
End Sub
I figured how to paste target after the last used cell, but I couldn't find a way to copy the recent dates from the other sheet.