Article ID: 139882
Article Last Modified on 10/11/2006
A1: 1 B1: C1: 3
A2: 2 B2: C2: 5
A3: 3 B3: C3: 8
A4: 4 B4: C4: 2
A5: 5 B5: C5: 0=IF(ISERROR(MATCH(A1,$C$1:$C$5,0)),"",A1)
A1: 1 B1: C1: 3 A2: 2 B2: 2 C2: 5 A3: 3 B3: 3 C3: 8 A4: 4 B4: C4: 2 A5: 5 B5: 5 C5: 0
Sub Find_Matches()
Dim CompareRange As Variant, x As Variant, y As Variant
' Set CompareRange equal to the range to which you will
' compare the selection.
Set CompareRange = Range("C1:C5")
' NOTE: If the compare range is located on another workbook
' or worksheet, use the following syntax.
' Set CompareRange = Workbooks("Book2"). _
' Worksheets("Sheet2").Range("C1:C5")
'
' Loop through each cell in the selection and compare it to
' each cell in CompareRange.
For Each x In Selection
For Each y In CompareRange
If x = y Then x.Offset(0, 1) = x
Next y
Next x
End Sub
A1: 1 C1: 3
A2: 2 C2: 5
A3: 3 C3: 8
A4: 4 C4: 2
A5: 5 C5: 0A1: 1 B1: C1: 3 A2: 2 B2: 2 C2: 5 A3: 3 B3: 3 C3: 8 A4: 4 B4: C4: 2 A5: 5 B5: 5 C5: 0
Additional query words: 8.00 XL98 XL97 XL7 XL5 match data XL
Keywords: kbdtacode kbhowto kbprogramming KB139882