compare to lists
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: compare to lists

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    New Member
    Join Date
    Apr 2002
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    =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.




User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com