+ Reply to Thread
Results 1 to 11 of 11

Changing values within a huge table

  1. #1
    Registered User
    Join Date
    11-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Changing values within a huge table

    Hello I have an extremely large tables of numbers (about 2000x2000). Each number corresponds to a name. I would like to replace these numbers as efficiently as possible. Find and replace is slow (not to mention there are 500+ names) and I tried creating a macro with cell.replace and that seemed just as slow. Is there a fast way for excel to do this or do I need to try another program? If I do need to try another program, which one and how fast will it be? Thanks

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Changing values within a huge table

    Hi wondering2
    Try this code in the attached workbook. It works between the list of numbers and names on sheet1 and changes all the numbers to names in sheet2.

    Please Login or Register  to view this content.
    Writing code seems to work for me tonight. Sometimes it takes much longer. enjoy.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Changing values within a huge table

    If you have a number corresponding to a name, do you have the names and numbers in a table?

    Any time you loop through a matrix of cells it is slow!

    It might be a good idea to post a small section of your data (perhaps a 10x10 grid), and if you have a list of names (change them if they are peoples or sensitive data)

    I am guessing that the quickest way is to read the names and numbers into arrays and the table and work with it all in memory, I think <5 seconds would be a good estimate of the time of a routine!

    Depending on your data layout and the numbers/names format of course!

    if the numbers are abitary then it will be slower if they are all sequential then it would be very fast!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Changing values within a huge table

    edit: below composed prior to above post - apologies for the repetition within

    I think with 4m cells to process you should be looking to work with VBA Arrays - the above routine would I think be quite slow on a large volume of data (even if you optimise App settings etc)

    It's not clear if the ID# are sequential etc or not - using MarvinP's sample file but extended to a 2000 x 2000 matrix we could run something like:

    Please Login or Register  to view this content.
    That said there are plenty out there better at working with Arrays far more efficiently than I - the above takes around 10 seconds on my machine but that's with 4GB RAM etc... so it will fluctuate.

    My guess is the better programmers around here will be able to improve upon that significantly - whilst also catering for the fact that the name table may not be in order or follow 1 to n pattern.

    Note: the above also assumes all Number entries are valid - ie no missing names - again this can be catered for if necessary.
    Last edited by DonkeyOte; 01-01-2011 at 06:32 AM.

  5. #5
    Registered User
    Join Date
    11-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Changing values within a huge table

    The one thing I didn't mention about the chart is that it has multiple numbers in each cell. It's kind of a big project, so again if anyone has a recommendation for a program that would be faster than excel let me know. I might be necessary that the program searches for the values " 1 " with the spaces instead of "1" so for instance the 1 in 201 isn't replaced.
    Attached Files Attached Files

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Changing values within a huge table

    Yikes

    So to be clear: you're saying you have a 2000 x 2000 matrix with each cell containing (potentially) a string detailing any number of "terms"
    (with each "term" to be translated per table)

    If so I have to say - though you can do this with VBA without too much difficulty (you can Split the terms easily enough [with an Application.Trim to remove superfluous spaces]) - it won't be particularly fast over that large a range.

    We can give you a working version for your sample but again when you run it in your "real" file you might as well go for a long lunch.

    At least that's my opinion... others may see it differently.

    On a final note: a number of "names" are blank in your sample - is this the case in your real file or did you simply get bored dummying values ?
    Last edited by DonkeyOte; 01-01-2011 at 12:33 PM.

  7. #7
    Registered User
    Join Date
    11-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Changing values within a huge table

    Sorry the chart are dummy names, I cannot put up the real names and 3500 fake names would take too long. I tried running previously and it took about 3 minutes a name, and I have 3500 names. I am considering trying matlab (not sure if it would be faster but maybe). If the code took multiple hours that would be ok, but I'm thinking that excel might not be viable if it takes in the 20+hours range

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Changing values within a huge table

    Final question:

    you have some IDs listed that don't appear in your list
    eg A1 contains 4680 yet names end at 3592

    is this the reality and if so what should happen to those "missing" ID values in the strings ?

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Changing values within a huge table

    Attached is your sample slightly revised (name listing so all populated)
    Where the "term" does not exist the "term" persists in the final string.

    I've added a BEFORE sheet so you can replace the results and test again etc... run "EXAMPLE" to translate SHEET1

    On a tiny sample file this will be pretty instantaneous, however, on a matrix containing 4 million cells it won't be ... though as mentioned before I'm sure there are big efficiency gains to be had with more thought / skill.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by DonkeyOte; 01-01-2011 at 12:59 PM. Reason: forgot to add point re: running Example to adjust Sheet1!

  10. #10
    Registered User
    Join Date
    11-01-2010
    Location
    London,England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Changing values within a huge table

    Unfortunately I got a memory error. I'm going to try splitting the chart up and then recombining them though. Thank you very much

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Changing values within a huge table

    What's the spec of the machine you're working on ?

    I took the sample 10 x 10 matrix and it's content and replicated that over a 2000 x 2000 matrix.

    Having created the 4million cell matrix I then ran the last routine I posted against it and the completed results were returned in around 140 seconds.

    Not great performance by any means but I did not encounter any issues myself.

    You must be running XL2007+ so I'd have a presumed a relatively new client with decent RAM etc...

+ 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