I have an error on doing the sumproduct function on the vba.
It should be sheet1(cont no) = sheet2(cont no) & sheet1(amount) = sheet2(amount)
then copy the sheet2 info into sheet3.
But why it will copy all info into sheet3 below is my coding.
Sheet 1
no Cont no amount
a 111 10
b 333 10
c 222 20
d 444 20
e 555 20
f 222 10
Sheet 2
no Cont no amount
a 111 20
b 333 20
c 333 10
d 444 20
e 555 20
f 222 10
sheet 3
no Cont no amount
a 111 20
b 333 20
With worksheets("sheet3")
lastrow = Worksheets("CMPK").Cells(Rows.Count, 1).End(xlUp).Row
Set R1 = Worksheets("CMPK").Range("A1:A" & lastrow)
Set R2 = Worksheets("CMPK").Range("C1:C" & lastrow)
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
.Range("Q11") = ""
Application.StatusBar = "Actioning 1 of 3 Row: " & i
cont_no = Cells(i, 2)
amount = Cells(i, 9)
myval = Evaluate("SumProduct(((" & R1.Address & ")= """ & cont_no & """) * ((" & R2.Address & ")<> """ & amount & """))")
If myval = 0 Then
Cells(i, 1).Resize(1, 12).Copy Destination:=.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
End If
End With
Next i
Bookmarks