Hello everyone!
I rely on your expertise for this!
I need to compare two columns on different sheets and get all the non-duplicates on a third sheet. I would like the results on the third sheet to be red-highlitened and to show the the same row content present on the first sheet.
The comparison needs to be as flexible as possible, because capital letters and spaces might differ substantially, but the content is still the same.
I begin with this code, but it doesnt seem to work:
Sub Compare()
Dim count1 As Integer
count1 = Sheet1.Range("A1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
Dim count2 As Integer
count2 = Sheet2.Range("A1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
Dim index As Integer
index = 1
Application.ScreenUpdating = False
For i = 2 To count1
For j = 2 To count2
If Sheet1.Cells(i, 1).Value <> "" Or Sheet2.Cells(j, 2).Value <> "" Then
If StrComp(Sheet1.Cells(i, 1).Value, Sheet2.Cells(j, 1).Value, vbTextCompare) <> 0 Then
Sheet3.Cells(index, 1).Value = Sheet1.Cells(i, 1).Value
index = index + 1
Exit For
End If
End If
Next j
Next i
End Sub
Please help me out! Thank you!!
I rely on your expertise for this!
I need to compare two columns on different sheets and get all the non-duplicates on a third sheet. I would like the results on the third sheet to be red-highlitened and to show the the same row content present on the first sheet.
The comparison needs to be as flexible as possible, because capital letters and spaces might differ substantially, but the content is still the same.
I begin with this code, but it doesnt seem to work:
Sub Compare()
Dim count1 As Integer
count1 = Sheet1.Range("A1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
Dim count2 As Integer
count2 = Sheet2.Range("A1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
Dim index As Integer
index = 1
Application.ScreenUpdating = False
For i = 2 To count1
For j = 2 To count2
If Sheet1.Cells(i, 1).Value <> "" Or Sheet2.Cells(j, 2).Value <> "" Then
If StrComp(Sheet1.Cells(i, 1).Value, Sheet2.Cells(j, 1).Value, vbTextCompare) <> 0 Then
Sheet3.Cells(index, 1).Value = Sheet1.Cells(i, 1).Value
index = index + 1
Exit For
End If
End If
Next j
Next i
End Sub
Please help me out! Thank you!!
