compare to lists

shivagopie

New Member
Joined
Apr 9, 2002
Messages
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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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.
 
Upvote 0
=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.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top