+ Reply to Thread
Results 1 to 3 of 3

Match columns and copy data from rows

Hybrid View

  1. #1
    Registered User
    Join Date
    03-13-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    2

    Match columns and copy data from rows

    Hi people,

    I have a file with columns A to BD and another file with columns A to BM.

    In column A in both files I have a customer ID. I would like to match File1 against File2 using only column A in both files and if there is a match in File2 I want the whole row copied from A to BD to File3 or just a new worksheet. Whatever seems best.
    The files contain everything from 100 to 9000 rows. But the main customer file only contains about 6000 rows.

    How can I do this? Let me know if you want something to work with and I will make some "dummie" files.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Match columns and copy data from rows

    See attached file 'Advanced Match two excel files' in wich I added macro 'MacroMatch'.

    You need to open, other the file above, other two files to match and these two files need to have key in column A. I added files File1 and File2 to try my macro.

    The macro matches two file writing data of two files one near other on the same row (if the key is present in both files).
    It also indicates source row number.

    Using filter you can easily select data you need.

    I hope it can help.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-13-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Match columns and copy data from rows

    The macro stops at STOP on the part below and refuses to continue. Line 74.

    'store keys in array
       For i = 1 To 2
          For r = 2 To nrRighe(i)
             key = ws(i).Cells(r, "a")
             If dic(i).exists(key) Then
                Stop
             Else
                dic(i).Add Item:=r, key:=key
             End If
          Next r
       Next i
    Could this be because I have some columns in one file set to hidden? Both A columns have the same format so this shouldn't be an issue. But it varies in every other column.

    Let me know if you need more information and if I have to strip my files with customer data to make bogus customer information then I will do just that.
    One file has 6142 rows including the titles (A1 to BE1) on each column, and the other file has 9646 rows with titles (A1 to BD1) on each column.
    Last edited by Xerfas; 03-19-2009 at 04:14 PM. Reason: Forgot to add the code within code tags

+ 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