Hi Friends
I'm trying to compare two ranges from different sheets:
- UniqueItems
- AllItems
but when I run the following code I get error message in IF condition (type mismatch)
Code:
Private Sub CommandButton1_Click()
With Sheets("UniqueItems")
.Range("A1").Select
.Range("G2:G65536").ClearContents
.Range("I1").ClearContents
End With
Dim i, j As Long
Dim Count, CountOrig As Integer
Dim LastRowAllItems As Long
Dim LastRowUniqueItems As Long
LastRowAllItems = Sheets("Allitems").Range("A65536").End(xlUp).Row
LastRowUniqueItems = Sheets("UniqueItems").Range("A65536").End(xlUp).Row
Count = 0
Sheets("UniqueItems").Range("I1") = "Processing ...."
For i = 2 To LastRowUniqueItems
For j = 2 To LastRowAllItems
If Sheets("UniqueItems").Range("A" & i & ":F" & i & "").Value = Sheets("AllItems").Range("A" & j & ":F" & j & "").Value Then
Count = Count + 1
Sheets("UniqueItems").Cells(i, "G") = Count
End If
Next j
Next i
MsgBox "Counting Items has been done successfully"
End Sub
Can anyone help to explain?