shahin
Active Member
I would like to create a macro which is capable of comparing "Names" and "Scroes" listed in Column "A" and Column "B" in "Sheet2" with those in Column "A" and Column "B" in "Sheet1". If there are duplicate values available, the macro should be able to kick those out from "Sheet2" as "Sheet1" is the main document holder and can't be removed. Once again: whether the document listed in "Sheet2" are themselves unique they may no longer be when compared to "Sheet1" so they should be removed from "Sheet2".
I've tried a macro (fully influenced by Narayan) which is capable of removing duplicates from "Sheet1" but my goal here is to make the macro start it's operation from "Sheet2" and compare its' values with "Sheet1". If any value matches, kick it from "Sheet2".
Here is what I've tried which is capable of removing duplicates from "Sheet1":
I'm attaching two "text" files pretending that the "text1" is holding what "Sheet1" holds and "text2" is holding what "Sheet2" does. Thanks in advance.
I've tried a macro (fully influenced by Narayan) which is capable of removing duplicates from "Sheet1" but my goal here is to make the macro start it's operation from "Sheet2" and compare its' values with "Sheet1". If any value matches, kick it from "Sheet2".
Here is what I've tried which is capable of removing duplicates from "Sheet1":
Code:
Sub RemoveDups()
Dim lrow&, R&, N&, dict As Object, cval As Variant
lrow = Sheet1.Range("A" & Rows.Count).End(xlUp).row
Set dict = New Scripting.Dictionary
For R = lrow To 2 Step -1
With Sheet1.Cells(R, 1)
cval = .Value ''cval stands for current value
If dict.Exists(cval) Then
.EntireRow.Delete
Else
N = N + 1: dict.Add cval, N + 1
End If
End With
Next R
End Sub
I'm attaching two "text" files pretending that the "text1" is holding what "Sheet1" holds and "text2" is holding what "Sheet2" does. Thanks in advance.