+ Reply to Thread
Results 1 to 4 of 4

Match values in a range with another range and copy the adjacent column

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Match values in a range with another range and copy the adjacent column

    Hello All,
    I am learning to write macros in excel and would appreciate your help. I have 4 values in column A1 through A4. I have another set of data in Column B1 through B100. I would like to check if the values in column A exist in column B and if it does then I would like the value in the adjacent cell (column C) to be copied in any other cell. I started structuring a program but I am not able to get what I want.

    Thanks.

  2. #2
    Registered User
    Join Date
    07-14-2011
    Location
    Ha Noi, Viet Nam
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Match values in a range with another range and copy the adjacent column

    Try this :
    PHP Code: 
    Option Explicit

    Sub Check
    ()
    Dim i As LongAs LongAs Long
    Dim ConD
    (), Arr(), dArr()
    With Sheet1
    ConD 
    = .Range("A1:A" & .[A65536].End(xlUp).Row).Value
    Arr 
    = .Range("B1:B" & .[B65536].End(xlUp).Row).Value
    ReDim dArr
    (1 To UBound(Arr), 1 To 1)

    For 
    1 To UBound(ConD1)
        For 
    1 To UBound(Arr1)
            If 
    Arr(i1) = ConD(j1Then
                k 
    1
                dArr
    (k1) = Arr(i1)
            
    End If
        
    Next
    Next
    .[C1].Resize(k1) = dArr
    End With
    End Sub 

    Thanks!!!!!
    Last edited by Cutter; 08-14-2012 at 11:48 AM. Reason: Removed whole post quote

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,540

    Re: Match values in a range with another range and copy the adjacent column

    If my understanding is correct

    =IFERROR(VLOOKUP(A1,$B$1:$C$10,2,FALSE),"")

    then copy down.

  4. #4
    Registered User
    Join Date
    08-13-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Match values in a range with another range and copy the adjacent column

    Thanks Jindon and Sunflowers. I ended up relpacing Vlookup with index match because I had several columns from which I needed the matching data and it worked. I will go over the macro now.

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1