I have this macro that finds the duplicates on sheet2 and sheet3 (Master list), then deletes the duplicates on sheet2.
However, as of late, I am getting an "Out of range" error on this macro. The columns that it references are D, E and F.
If anyone could take a look at this code and see if i could have done something in error, it would be greatly appreciated!
- Sub duplicates()
- Dim a, b, c()
- Dim i As Integer, x As Long, y As Integer, z As Integer
- a = Sheets(2).Range("b2").CurrentRegion.Value
- b = Sheets("Master Tracking").Range("b2").CurrentRegion.Value
- ReDim c(1 To UBound(a, 1), 1 To UBound(a, 2))
- For i = 1 To UBound(a, 1)
- For x = 1 To UBound(b, 1)
- If a(i, 4) = b(x, 4) And a(i, 5) = b(x, 5) And a(i, 6) = b(x, 6) Then
- Exit For
- End If
- If x = UBound(b, 1) + 1 Then
- z = z + 1
- For y = 1 To UBound(b, 2)
- c(z, y) = a(i, y)
- End If
- With Sheets(2).Cells(1, 1).Resize(UBound(c, 1), UBound(c, 2))
- .Value = c
- End With
- End Sub