Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Compair first 5 numbers

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Compair first 5 numbers

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

"Srenfro" skrev i meddelelsen
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
compair bbrodsky Excel Worksheet Functions 1 August 11th 09 06:29 PM
compair 2 excel file's and import data from 1 to the other Steven Van Laethem Excel Discussion (Misc queries) 1 July 30th 09 11:02 PM
Compair two sheets and return differences Don Excel Discussion (Misc queries) 0 January 21st 08 01:37 AM
How to Compair two Excel files using Macro ? Nitesh Mathur Excel Programming 4 October 9th 07 12:46 AM
need to compair two excell docs and find the changes Richard 66 Excel Discussion (Misc queries) 2 August 10th 06 09:52 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"