I have two sheets that I need to remove duplicates from "TestData" has two columns(A and C) of account numbers, and "Master" has two columns(A and B) account numbers and date. I need to compare the "Master" and "TestData" column C for duplicates and removed based on the following.
Compare "Master" account numbers and "TestData" Column C, if duplicates and > 41 days old from =Today() remove duplicates from "Master", else if duplicates and <= 41 days old from =Today() remove duplicates from "TestData" Column C.
My original issue was removing duplicates from "Master" and "TestData" Column A, if duplicates remove from "TestData" Column A, which I'm currently using the following code. Which I snagged from a video and changed to fit my needs to remove duplicates from two sheets:
How can I modify this or do I need something else?
Thanks in advance
Compare "Master" account numbers and "TestData" Column C, if duplicates and > 41 days old from =Today() remove duplicates from "Master", else if duplicates and <= 41 days old from =Today() remove duplicates from "TestData" Column C.
My original issue was removing duplicates from "Master" and "TestData" Column A, if duplicates remove from "TestData" Column A, which I'm currently using the following code. Which I snagged from a video and changed to fit my needs to remove duplicates from two sheets:
Code:
Sub RemoveDupsBetweenLists()
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim C1row As Long
Dim C2row As Long
Dim C2TotalRows As Long
Dim AccountNum As String
Dim NoDups As Long
Set sht1 = Worksheets("Master")
Set sht2 = Worksheets("TestData")
sht1.Activate
C2TotalRows = Application.CountA(Range("A:A"))
C1row = 2
Do While sht2.Cells(C1row, 1).Value <> ""
AccountNum = sht2.Cells(C1row, 1).Value
For C2row = 2 To C2TotalRows
If AccountNum = Cells(C2row, 1).Value Then
sht2.Activate
Rows(C1row).Delete
NoDups = NoDups + 1
C1row = C1row - 1
sht1.Activate
Exit For
End If
Next
C1row = C1row + 1
Loop
MsgBox NoDups & " Duplicates were removed"
End Sub
How can I modify this or do I need something else?
Thanks in advance