I have an Excel document where VBA code copies two columns for each row from Sheet-1 into Sheet-2.
I would like to copy those two columns only if the specific row's date is greater than today's date + 6 months. The date should not be copied into Sheet-2.
To specify the above:
I have a sheet called "Banks" (Sheet-1). The ISIN-code and Common name is copied into another sheet called "New Banks" (Sheet-2).
In the sheet "Banks" (Sheet-1) the company's call date is also stated in column "G". I would like this to be the determining factor (if call date is not within 6 months) of whether the row should be copied.
Sub Copydata()
Application.ScreenUpdating = False
Dim Ws, wsBank, As Worksheet
Dim LastRow As Long
Set wsBank = Sheets("New Banks")
wsBank.Range("a3:b1000").ClearContents
'Banks
Set Ws = Sheets("Banks")
LastRow = Ws.cells(1000, 1).End(xlUp).Row
If Ws.cells(LastRow, 1) = "" Then
Else
Ws.Range("B2:C" & LastRow).Copy
wsBank.Range("A" & 3).PasteSpecial Paste:=xlPasteValues
End If
End Sub
I would like:
If Sheets("Banks").Range("G2") > Today + 6 months then
Copy and paste
If not then next row

dateadd("M", 6, date)