![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 1
|
Friends:
List A = 1000 serial numbers eg. 75TCB11 List B = 100 serial numbers Task: To find List B numbers wherever located in List A. Solution: ?? A macro maybe, or other? Help |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
Sub AlignCols() 'XXXXXXXXXXXXline1XXXXXXXXXXXX Dim LastBRow, i, IndexNum As Long 'XXXXXXXXXXXXline2XXXXXXXXXXXX LastBRow = Range(Range("B1"), Range("B1").End(xlDown)).Rows.Count 'XXXXXXXXXXXXline3XXXXXXXXXXXX For i = LastBRow To 2 Step -1 'XXXXXXXXXXXXline4XXXXXXXXXXXX IndexNum = Application.WorksheetFunction.Match(Range("B" & i), Columns("A"), 0) 'XXXXXXXXXXXXline5XXXXXXXXXXXX Range("B" & i).Select 'XXXXXXXXXXXXline6XXXXXXXXXXXX Selection.Cut Destination:=Cells(IndexNum, 2) 'XXXXXXXXXXXXline7XXXXXXXXXXXX Next End Sub I wrote this code for someone yesterday. Just make sure that the two lists are sorted.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 30
|
=COUNTIF(C1..C100,A1)
This assumes you aren't after the location of a match, just whether or not the item appears on the other list. If your List A is cells A1..A1000, this formula goes in B1..B1000. C1..C100 is your List B. COUNTIF will return 1 if the item in A1 appears anywhere in List B, 0 if it does not. To make it visually easier, enlcose that formula in an IF statement: =IF(COUNTIF(C1..C100,A1),"YES","") 1 is another way of saying TRUE, 0 another way of saying FALSE, so this one will show YES for a match and formula generated blank for a non-match. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|