hello
I got this code is very well , but the problem it shows only the data are existed in sheet1 and is not existed in sheet2 I would also shows data what is existed in sheet2 but is not existed in sheet1
I got this code is very well , but the problem it shows only the data are existed in sheet1 and is not existed in sheet2 I would also shows data what is existed in sheet2 but is not existed in sheet1
VBA Code:
Sub NewEntry()
Dim OldDict As Object, arrIn As Variant, arrOld As Variant, arrNew() As Variant, a As Long, r As Long
Set OldDict = CreateObject("Scripting.Dictionary")
arrIn = sheet1.Range("A1:c6").Value
arrOld = sheet2.Range("A1:c6").Value
'prior values
With OldDict
.CompareMode = vbTextCompare
For a = 1 To UBound(arrOld)
If Not .Exists(arrOld(a, 1)) Then OldDict.Add arrOld(a, 1), arrOld(a, 1)
Next a
'get new values
ReDim arrNew(1 To UBound(arrIn), 1 To 3)
For a = 1 To UBound(arrIn)
If Not .Exists(arrIn(a, 1)) Then
r = r + 1
arrNew(r, 1) = arrIn(a, 1)
arrNew(r, 2) = arrIn(a, 2)
arrNew(r, 3) = arrIn(a, 3)
End If
Next a
End With
'write to sheet
sheet3.Range("a2").Resize(UBound(arrIn), 3).Value = arrNew
End Sub