L
ll
Hi,
I am working with a script to try and return non matches. I have set
up two ranges and have set up nested loops to compare them. The
problem I'm currently having is that, even with the operator set to
"<>", even the matches get returned for some reason.
Does anyone have any ideas as to why this would do that? (Script
below)
Thanks very much,
Louis
======================
Sub Find_Matches()
Dim CompareRange1 As Variant, x1 As Variant, y1 As Variant
Dim CompareRange2 As Variant, x2 As Variant, y2 As Variant
' Set CompareRange equal to the range to which you will
' compare the selection.
Set CompareRange1 = Worksheets("Sheet1").Range("A1:A5")
Set CompareRange2 = Worksheets("Sheet2").Range("A1:A5")
' Loop through each cell in the selection and compare it to
' each cell in CompareRange.
For Each x1 In CompareRange1
For Each y2 In CompareRange2
If x1 <> y2 Then x1.Offset(0, 1) = x1
Next y2
Next x1
End Sub
I am working with a script to try and return non matches. I have set
up two ranges and have set up nested loops to compare them. The
problem I'm currently having is that, even with the operator set to
"<>", even the matches get returned for some reason.
Does anyone have any ideas as to why this would do that? (Script
below)
Thanks very much,
Louis
======================
Sub Find_Matches()
Dim CompareRange1 As Variant, x1 As Variant, y1 As Variant
Dim CompareRange2 As Variant, x2 As Variant, y2 As Variant
' Set CompareRange equal to the range to which you will
' compare the selection.
Set CompareRange1 = Worksheets("Sheet1").Range("A1:A5")
Set CompareRange2 = Worksheets("Sheet2").Range("A1:A5")
' Loop through each cell in the selection and compare it to
' each cell in CompareRange.
For Each x1 In CompareRange1
For Each y2 In CompareRange2
If x1 <> y2 Then x1.Offset(0, 1) = x1
Next y2
Next x1
End Sub