Teleporpoise
New Member
- Joined
- May 23, 2019
- Messages
- 31
Hello Mr. Excel Friends,
I am copying rows of data from various workbooks into one workbook. The data in the workbooks will be cleared out weekly, but will be collected daily. Therefore I will have the issue of duplicates with this code:
As you can see, I am copying the whole row of data. I have this same code multiple times in the sheet with references to different workbooks.
The other issue that I will encounter is that I want to prevent duplicates based on the info in the whole row. What I mean is, I might have duplicates in column A for two rows, but not column B, and so I wish to copy the two duplicate rows as the B values are different.
Can I avoid copying duplicates from the same sheet? Or can I have a code or macro for the whole sheet that finds duplicate rows and deletes them?
Thank you for your help
I am copying rows of data from various workbooks into one workbook. The data in the workbooks will be cleared out weekly, but will be collected daily. Therefore I will have the issue of duplicates with this code:
Code:
Private Sub GTB_Click()
Dim LastRow As Integer
Dim i As Integer
Dim erow As Integer
Dim GTBT As Workbook
Dim Traceability As Worksheet
Set Traceability = ThisWorkbook.Worksheets("Traceability")
Workbooks.Open Filename:="\Libraries\Documents\WS1.xlsm"
Set GTBT = Application.Workbooks("WS1.xlsm")
GTBT.Worksheets("FR").Select
LastRow = GTBT.Worksheets("FR").Range("A" & Rows.Count).End(xlUp).Row
For i = 5 To LastRow
GTBT.Worksheets("FR").Range(GTBT.Worksheets("FR").Cells(i, 1), GTBT.Worksheets("FR").Cells(i, 17)).Copy
Traceability.Cells(Traceability.Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'ActiveWorkbook.Save
'ActiveWorkbook.Close
Application.CutCopyMode = True
Application.CutCopyMode = False
Next i
GTBT.Close
End Sub
The other issue that I will encounter is that I want to prevent duplicates based on the info in the whole row. What I mean is, I might have duplicates in column A for two rows, but not column B, and so I wish to copy the two duplicate rows as the B values are different.
Can I avoid copying duplicates from the same sheet? Or can I have a code or macro for the whole sheet that finds duplicate rows and deletes them?
Thank you for your help