Hello,
I was using JLGWhiz's code to append entries from a data source to to my target workbook. Currently, it looks from the bottom and removes the duplicates. How would I modify it to preserve the previous entries in the target workbook and add the new entries in order?.
Thanks,
CG
Original Post : Appending data and removing duplicates
I was using JLGWhiz's code to append entries from a data source to to my target workbook. Currently, it looks from the bottom and removes the duplicates. How would I modify it to preserve the previous entries in the target workbook and add the new entries in order?.
VBA Code:
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, i As Long, fn As Range
Set sh1 = targetWorkbook.Sheets(SheetName) 'Master
Set sh2 = QlikWorkbook.Sheets(1) 'Qlik Data
lr = sh1.Cells(Rows.Count, 1).Row
For i = 2 To lr 'Assumes header on new sheet.
With sh2
Set fn = sh1.Range("A:A").Find(.Cells(i, 1).Value, .Range("A1"), xlValues, xlWhole, xlByRows, xlPrevious)
If Not fn Is Nothing Then
.Cells(i, 1).EntireRow.Copy fn
End If
End With
Next
Thanks,
CG
Original Post : Appending data and removing duplicates
Last edited by a moderator: