+ Reply to Thread
Results 1 to 13 of 13

Compare & Fill Data - Large Data Sets - Question

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Compare & Fill Data - Large Data Sets - Question

    Hi,
    i have been struggling with a problem for a while now and i hope some of you guys may be able to help me.

    Basically I am trying to compare data in two columns and in case of a match fill a third column of data. Everything seems to be easy but the one problem is that the columns i compare contain hundreds of thousands of data values (rows). Meaning that in the on example i am working on i have to do a 700000x800000 rows matching, which will take probably days (i never reached the end, i break up my macro after a couple of hours)

    I've saved a copy of my data on the following address:

    https://app.box.com/s/cp3zd7sgexjcxzjhy3lp


    In the example provided i'm trying to do the following:
    Compare values from sheet States column L with Sheet1 column A and if there is a Match, check the Index in States sheet (column K) and put 1 of the corresponding column in Sheet1 and 0 to all other columns in sheet 1 (J:S)

    3 Macros are included in the file which all do the job but for this data size are practically not applicable.

    My question is, is it possible to modify the code in a way that a reasonable run time is achieved? Its clear to me that it wont be finished in minutes but a couple of hours will be great.


    Thank you in advance.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare & Fill Data - Large Data Sets - Question

    Hi Mitko,
    can there be multiple matches in column L (States) and column A (Sheet1)?

  3. #3
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Compare & Fill Data - Large Data Sets - Question

    I haven't looked at your file (I have a bit of a phobia about downloading executables from the web) but I can tell you that when working with large data sets, it is much quicker to read the data into arrays and compare them in memory vs reading from cells in a spreadsheet. Just dimension a couple arrays as variant, then set the arrays equal to the ranges you need to examine. That should work much faster.

  4. #4
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Compare & Fill Data - Large Data Sets - Question

    No there shouldn't be any multiple matches, however due to some measurements errors it could happen that there some (which can be ignored)

  5. #5
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Compare & Fill Data - Large Data Sets - Question

    Quote Originally Posted by gjcase View Post
    .. it is much quicker to read the data into arrays and compare them in memory vs reading from cells in a spreadsheet.
    Hi,
    thanks for the effort. Your suggestion is exactly the way i am proceeding at the moment. However it still requires a enormous amount of time.


    Best Regards

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare & Fill Data - Large Data Sets - Question

    Mitko,
    unexpected difficulties arose. I copied some of your data to a new file (attached). There are discrepancies between the data that must meet. For example, the macro ttt() says F6 on Sheet1 is not equal to the L6 on States.
    Perhaps this is due to regional settings. You ttt() macro gives the same values ​​as me?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Compare & Fill Data - Large Data Sets - Question

    Nilem,
    i assume this is a result of converting the Date to Unix format. Perhaps there is a decimal point somewhere i the data on the States sheet. I had some similar problems and i solved it by converting the values to strings, or, if you know a way to cut the decimal part. The first couple of decimal digits are 0 but i am quite sure somewhere there is a value and that makes the difference.

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare & Fill Data - Large Data Sets - Question

    Okay, change the formula in column L on a sheet of States as follows:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The macro is almost ready, I just will check at runtime. Do not go away

  9. #9
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Compare & Fill Data - Large Data Sets - Question

    Thanks mate, just make sure you check it on the large data set i provided, because that's where trouble came before

  10. #10
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare & Fill Data - Large Data Sets - Question

    Here's a file with two macros. ertert() advantageous to use, if there are a large number of matches. If a small number of matches, it is best to apply ertert22(). Both macros are checked on your data, both run about 40 seconds.
    Just copy the modules with these macros in your file.
    Pre I changed the formula in your original file and copied piece of data in my file.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-25-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Compare & Fill Data - Large Data Sets - Question

    Nilem,
    man you are absolutely the greatest! It really worked fast. I've been asking for help about this since more than a week in different online sources and no one managed to solve it. You really helped me a lot. I don't know how to thank you!!!
    However there is one thing that still needs a small correction. For the cells in J:S on sheet1 i need zeros in case of no match. Your code inserts the 1's but leaves the other cells empty.

    I have a code that i wrote, and it works...needs a couple of minutes but its not a big pain.

    Please Login or Register  to view this content.
    Is there a smarter way of doing this (i know there is since i'm far away from an epert in vba)?
    Last edited by mitko007; 07-25-2013 at 05:11 PM.

  12. #12
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Compare & Fill Data - Large Data Sets - Question

    Please Login or Register  to view this content.

  13. #13
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Compare & Fill Data - Large Data Sets - Question

    Hi Mitko
    you can use this modified code
    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. [SOLVED] Data Thinner code seems very inefficient- used on large data sets
    By Canuckle777 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2013, 10:29 AM
  2. data problems, matching large data sets with smaller known points
    By awguest1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-28-2013, 08:48 PM
  3. [SOLVED] How to merge two data sets to create a single large data set.
    By Econocrat in forum Excel General
    Replies: 5
    Last Post: 10-06-2012, 04:02 PM
  4. Replies: 5
    Last Post: 11-16-2009, 04:44 PM
  5. Data matching from 2 large data sets
    By chemnerd1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2008, 04:22 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