Compair first 5 numbers

S

Srenfro

Hello all i have a question i need to compair only the first 5 or 6 numbers
in Collumn A and Collumn B and put a the result in c I have it to right now
where it will compair the whole list is there a way to get it to do only the
first 5 0r 6 numbers my macro that i have for compairing the whole list is

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("A1:A3000")
' 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

thank you

Stephen
 
P

Per Jessen

Hi Stephen

Try this

For Each x In Selection
For Each y In CompareRange
If Left(x, 5) = Left(y, 5) Then x.Offset(0, 1) = x
Next y
Next x

Regards,

Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top