+ Reply to Thread
Results 1 to 11 of 11

Trying to match data from two different tables and copy and paste data to one table

  1. #1
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Trying to match data from two different tables and copy and paste data to one table

    Hello, I'm trying to figure out the correct way to match data in two separate lists. The match is the five digit numbers Once a match is found, then the next column in the second list copies the data from the next column and pastes it to the column next to the match in the first list. For example;

    List 1
    zone cals
    10027 15
    10010 32
    10036 35


    List 2
    zones Numb
    10036 35
    10027 15
    10010 32


    I would like this to be dynamic if possible because these five digit numbers change. If a match is not found, then I just want it to be ignored. No #NA.

    Please advise. Your assistance will be greatly appreciated. I was using vlookup, match with no luck.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Trying to match data from two different tables and copy and paste data to one table

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Re: Trying to match data from two different tables and copy and paste data to one table

    Okay here is the attachment.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    As a beginner starter :

    PHP Code: 
    Sub Demo1()
            
    Dim VR&, Rg As Range
        With Sheet1
    .Range("A3"Sheet1.[A2].End(xlDown))
                
    = .Value2
            
    For 1 To UBound(V)
                
    Set Rg Sheet2.UsedRange.Columns(1).Find(V(R1), .Cells(21), , xlWhole)
                 If 
    Rg Is Nothing Then V(R1) = "" Else V(R1) = Rg(12).Value2
            Next
                Set Rg 
    Nothing
               
    .Offset(, 1).Value2 V
                Sheet2
    .UsedRange.Copy .Parent.[C1]
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Trying to match data from two different tables and copy and paste data to one table

    And another way:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Re: Trying to match data from two different tables and copy and paste data to one table

    Yes! That did exactly what I needed it to do. I'm still learning this stuff since the one who knows this moved on.

  7. #7
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Re: Hi ! Try this !

    Thank you for the help. I'm still new to VBA and Excel.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb The easy Excel way …


    Without any loop, just with Excel 2007+ basics (as previous demo was under 2003 version),
    as a beginner starter :

    PHP Code: 
    Sub Demo2()
        
    Dim A$
            
    Sheet2.Range("A3:B" Sheet2.UsedRange.Rows.Count).Address(External:=True)
        
    With Sheet1
            With 
    .Range("B3:B" & .UsedRange.Rows.Count)
                 .
    Formula "=IFERROR(VLOOKUP(A3," ",2,FALSE),"""")"
                 
    .Formula = .Value2
            End With
                Sheet2
    .UsedRange.Copy .[C1]
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  9. #9
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Re: The easy Excel way …

    Hello there,

    Thanks for responding. Attached is the sample of what I'm trying to do.

    Take the values under column I and paste it to the Zip Code associated with it where it's already listed under column A in the same position.
    This changes from time to time so it has to me dynamic.


    Hopefully, it's something simple that I'm overlooking.

    Thanks.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-13-2016
    Location
    Richmond, NY
    MS-Off Ver
    2010
    Posts
    16

    Re: Hi ! Try this !

    Hello again,

    Thanks for the code. But for some reason I'm getting an object not found error. please see attachment of screen shot. I tried revising
    but it keeps coming up.

    Thanks
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Trying to match data from two different tables and copy and paste data to one table


    As you can see in the VBE Project window the CodeName of the worksheet "Sheet2" is not Sheet2 but Sheet4 …

    … so replace each Sheet2 by Sheet4 within the procedure.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy a table hidden & visible row data & paste all data
    By How How in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2015, 01:43 PM
  2. Replies: 2
    Last Post: 07-18-2015, 05:19 PM
  3. Match and copy and paste data to another sheet.
    By Macfool in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-26-2015, 08:26 AM
  4. Copy and paste data between tables in separate workbooks.
    By catigo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2013, 04:41 PM
  5. How to get the copy & paste if data is match
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2013, 07:37 PM
  6. [SOLVED] Copy Data from a Column and Paste Value to a data table
    By davegib in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2012, 05:19 AM
  7. Replies: 1
    Last Post: 04-07-2011, 01:21 AM

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