+ Reply to Thread
Results 1 to 19 of 19

comparing two excel files and saving the unique records in file 1

  1. #1
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    comparing two excel files and saving the unique records in file 1

    Hi friends

    I have to compare two excel file 1 and file2

    compare column N from file 1 to file 2, if duplicate records found in file 2 delete and paste unique records found In file 2 to a new worksheet with file 1 records and then unique records from file2 as a combined new workbook as history workbook.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Hi Friends

    I am using the below code, but it doesn't copy the unique value from file 2.
    Please Login or Register  to view this content.
    Please help.

  3. #3
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    Try this .. change the items in red

    Please Login or Register  to view this content.
    Last edited by mongoose36; 08-08-2014 at 01:48 AM.
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  4. #4
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    Try this .. change the items in red

    Please Login or Register  to view this content.

    Just testing it and I have a question, Why does it take so long when I run the macro, though it uses array, it should be faster, I have 3000 records only.

    Thanks for the code.

  5. #5
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    The bottle neck occurs at the for loop that evaluates each cell.

    Try this it uses 2 array loops instead.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    The bottle neck occurs at the for loop that evaluates each cell.

    Try this it uses 2 array loops instead.

    Please Login or Register  to view this content.
    =======================================

    Hi
    Thanks for the help.
    I want to copy all the remaining values in file 2 to sheet 1 of file1 , how can I make changes to the code. also I want to delete the 7 days of top row data in file 1.
    Last edited by irfanparbatani; 08-10-2014 at 10:18 PM.

  7. #7
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by irfanparbatani View Post
    =======================================

    Hi
    Thanks for the help.
    I want to copy all the remaining values in file 2 to sheet 1 of file1 , how can I make changes to the code. also I want to delete the 7 days of top row data in file 1.
    =================================================

    Can we copy the entire matching row from sheet 2 to unique values?

  8. #8
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    Try changing this...
    Please Login or Register  to view this content.
    to this...
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    Try changing this...
    Please Login or Register  to view this content.
    to this...
    Please Login or Register  to view this content.

    =====

    Thank you for your help, much appreciated. but can we paste the values at the end of sheet 1 all the unique values. also need to delete 7 days of data from sheet 1 on the top.

  10. #10
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    Try changing this...
    Please Login or Register  to view this content.
    to this...
    Please Login or Register  to view this content.

    =====

    Thank you for your help, much appreciated. but can we paste the values at the end of sheet 1 all the unique values. also need to delete 7 days of data from sheet 1 on the top.

  11. #11
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Hi

    This process still freezes my excel and i have to force close it. too slow if data is large in file 1. Will Filtering the data find help me to get the process faster.

  12. #12
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    The bottle neck occurs at the for loop that evaluates each cell.

    Try this it uses 2 array loops instead.

    Please Login or Register  to view this content.

    ===
    The above code does not delete the value from ws2 when the match is found in sheet1. can you please check and respond me. sheet 1 is .csv extension and sheet2 is .xlsm extension, does that bother us from performing the above operation.
    Thanks
    Last edited by irfanparbatani; 08-12-2014 at 04:29 AM.

  13. #13
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    Sorry for taking so long to get back to you. I don't see where you have changed the path or file name in the above code. These would need to be changed to your specific path and file names.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    I don't think the fact the on workbook is csv will effect the operation of the code as long as excel is opening it.

    In my tests everything worked as expected.

  14. #14
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Hi Cpl

    Thank you for replying. I changed the path and file 1is csv which will be compared and file 2 will be xlsm where the main data is pasted in one of the sheets. I tried a lot but it just gives me the same data which is in file 2. It does not delete rows found in sheet 2.
    Please help and also the macro freezes up the excel if there are more than 2000 records.

  15. #15
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    Please post your workbook...

    Also could you please clarify the logic ...
    Quote Originally Posted by irfanparbatani View Post
    Hi friends

    I have to compare two excel file 1 and file2

    compare column N from file 1 to file 2, if duplicate records found in file 2 delete and paste unique records found In file 2 to a new worksheet with file 1 records and then unique records from file2 as a combined new workbook as history workbook.

    Thanks
    Eg...

    1. Open File 2 (csv) from File 1 (xlsm)
    2. Compare data in N Column of File 1 to column N of File 2
    a. if match is found delete the entire row
    3. Copy unique values left (if any) in File 2 to new worksheet titled "Unique Values" in File 1
    4. It gets a little fuzzy here...

  16. #16
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by cplettner View Post
    Please post your workbook...

    Also could you please clarify the logic ...


    Eg...

    1. Open File 2 (csv) from File 1 (xlsm)
    2. Compare data in N Column of File 1 to column N of File 2
    a. if match is found delete the entire row
    3. Copy unique values left (if any) in File 2 to new worksheet titled "Unique Values" in File 1
    4. It gets a little fuzzy here...
    ====

    Hi mate
    Except point 3, just delete the row in file 2 and do not copy over the unique value from file 1.

    Attaching workbook soon.

  17. #17
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    workbook attached
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    07-30-2012
    Location
    australia
    MS-Off Ver
    Excel 2003
    Posts
    118

    Re: comparing two excel files and saving the unique records in file 1

    Also file 2 will open file 1 and file 1 is the compare dictionary, it would paste new 7 days data every time compare is performed.

  19. #19
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: comparing two excel files and saving the unique records in file 1

    Quote Originally Posted by irfanparbatani View Post
    Also file 2 will open file 1 and file 1 is the compare dictionary, it would paste new 7 days data every time compare is performed.
    Ha Ha I've been thinking of it the exact opposite!

+ 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. [SOLVED] Comparing records to result in a list of unique records
    By greenmat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2013, 07:45 PM
  2. Difference in file size when saving excel files.
    By jonelamora in forum Excel General
    Replies: 3
    Last Post: 04-11-2013, 01:19 PM
  3. Export Unique Values from two excel files into a third file
    By pwilkes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2013, 06:14 PM
  4. Replies: 2
    Last Post: 01-04-2013, 07:22 AM
  5. [SOLVED] Saving each row of an excel file in separate excel files
    By acamci in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2006, 05:10 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