+ Reply to Thread
Results 1 to 8 of 8

Extracting matched and unmatched records from two text files

  1. #1
    Registered User
    Join Date
    05-30-2015
    Location
    Delhi, India
    MS-Off Ver
    2003
    Posts
    4

    Extracting matched and unmatched records from two text files

    Hi, Everyone

    I have two pipe delimited text files. I need to extract matched records from these two files and unmatched records only from one (based on combination of two fields present in both files, uniquely identifying each record), and want these records in a separate third file. Both these files have over 80,000 records. I wrote a macro but it takes too much of time to execute. How can this be done with macro in an efficient way, that saves time? Also, Is there any useful method or procedure of excel/macro that can do this job quickly? Please help.

  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: Extracting matched and unmatched records from two text files

    Hi singsum,

    Welcome to the Forum!

    It sounds as though a dictionary approach and a range union would work nicely

    Attach a sample workbook. 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 use the paperclip icon to open the upload window.

    View Pic
    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-30-2015
    Location
    Delhi, India
    MS-Off Ver
    2003
    Posts
    4

    Re: Extracting matched and unmatched records from two text files

    Hi xladept,

    Thanks, for the quick reply .

    I am afraid that, i think i followed the dictionary approach in the code, but am not sure about the Range union thing. And I am still not sure how to do for 80,000 records .

    I have attached a sample workbook in the BEFORE and AFTER sheets format as suggested by you. It contains enough data for what i am trying to do.
    Attached Files Attached Files

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

    Re: Extracting matched and unmatched records from two text files

    Hi Singsum,

    Thanks for the rep!

    The range union would have been to delete the "Extracted" records - but that's not really what's happening

    Please Login or Register  to view this content.
    *If this still too slow, we may be able to speed it up with arrays.
    Last edited by xladept; 05-31-2015 at 10:17 PM.

  5. #5
    Registered User
    Join Date
    05-30-2015
    Location
    Delhi, India
    MS-Off Ver
    2003
    Posts
    4

    Re: Extracting matched and unmatched records from two text files

    Hi xladept,

    Thanks for the solution. I really appreciate that.

    I get that, it does pretty much the same what i wanted.

    But here is the problem .
    In excel it looks pretty much good to handle, but what do i need to do if i have to do it originally in the pipe delimited text files (File 1 and File 2) which will be used as input and Write that to the third text file (this also should be pipe delimited). I have attached a text file which contains the macro i am using.

    Please have a look and suggest the ways of improvement.
    Attached Files Attached Files

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

    Re: Extracting matched and unmatched records from two text files

    I can't test it so it, if it works at all, will need some tweaking - Let me know!

    Please Login or Register  to view this content.
    Last edited by xladept; 06-01-2015 at 11:53 PM. Reason: Tidying Up

  7. #7
    Registered User
    Join Date
    05-30-2015
    Location
    Delhi, India
    MS-Off Ver
    2003
    Posts
    4
    Hi, Xladept

    Quote Originally Posted by xladept View Post
    I can't test it so it, if it works at all, will need some tweaking - Let me know!

    Please Login or Register  to view this content.
    When i executed, it is showiing error msg, "subscript out of range". I debugged, it is in the line
    Set w3=Workbooks(file3).Sheets("Sheet1").

    I guess it has something to do with, the file3 in the bracket.
    What needs to be changed here?

    And just to remind, i work on excel 2003 version, so hope it has nothing to do with that.

    Also, in excel 2003, max range allowed is 65536, so would it pose a problem, if my file file1, file2 have over 80-90,000 records.

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

    Re: Extracting matched and unmatched records from two text files

    Hi Singsum.

    Too many records would be a big problem - as for the subscript error the name must be exact - maybe:

    Please Login or Register  to view this content.

+ 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. Macro for unmatched records
    By toravietl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2014, 09:51 AM
  2. [SOLVED] Update matched records when import
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-10-2013, 07:19 AM
  3. [SOLVED] Comparing two excel files and copy Unmatched
    By peter.hernadi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-27-2013, 08:23 AM
  4. Find unmatched records in Access
    By ewong in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-14-2012, 06:46 PM
  5. How to compare 2 columns for matched / unmatched records
    By ASP__DEVELOPER in forum Excel General
    Replies: 2
    Last Post: 04-22-2010, 10:35 AM

Tags for this Thread

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