Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
I need to only copy newly pasted values to another workbook. How could I adjust this code to make that work.
VBA Code:
Private Sub CopyData()
Dim SourceWb As Workbook, DestWb As Workbook
Dim SourceWs As Worksheet, DestWs As Worksheet
Dim IfDataExist As Boolean
Dim tbl As ListObject
Dim Rng As Variant, FileToOpen As Variant
Dim LRow As Long, Row As Long
With Application
.EnableEvents = False
.ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
Set SourceWb = Workbooks("2023BackOrderReport.xlsm")
Set SourceWs = SourceWb.Worksheets("Data")
LRow = SourceWs.Cells(Rows.Count, 1).End(xlUp).Row
Set Rng = SourceWs.Range("A2:A" & LRow)
FileToOpen = ("S:\SALES\ADMIN\Intact Import\DR - Sales Order BO Report.xlsx")
Workbooks.Open FileToOpen
Set DestWb = Workbooks("DR - Sales Order BO Report.xlsx")
Set DestWs = DestWb.Worksheets("BOReported")
Set Rng = DestWs.Range("A2:A" & LRow)
DestWs.Range("A2").CurrentRegion.Delete
SourceWs.Range("A2:A" & LRow).Copy
DestWs.Range("A2:A" & LRow).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub