+ Reply to Thread
Results 1 to 6 of 6

More efficient (faster) sub-String method?

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    Ottawa, Canada
    Posts
    29

    More efficient (faster) sub-String method?

    I have a piece of code that works very well but takes a long time. 1s per instance to be exact. My data is going to approach 3000 records so that translates into almost an hour to run through the entire data set.
    I am looking for code that will produce the same results but in much less time. Is it possible?

    Basically I have a Column that contains names with English and French acronyms separated by [space]/[space]. I need just the English acronym.

    Group Name:
    ABCDEFG / ABCGDF
    XYZ / ZXY
    ABC123 / CAB123

    Changes to....

    Group Name:
    ABCDEFG
    XYZ
    ABC123

    This is the code I am using:

    Please Login or Register  to view this content.
    Last edited by Bytor47; 06-12-2013 at 08:21 AM. Reason: Solved

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: More efficient (faster) sub-String method?

    How about amending the following to suit the range you want to go through
    Please Login or Register  to view this content.
    It places the split string to the right of each cell it loops through. I think this should be quicker.

    EDIT: I just tested this on about 25,000 rows and it finished in about 3 seconds.
    Last edited by Mordred; 06-11-2013 at 01:57 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: More efficient (faster) sub-String method?

    You might want to try Data>Text to columns... with / as a delimiter and skipping the second column.

    I just tried that on 15000 rows of data similar to yours, it was quite quick.
    Last edited by Norie; 06-11-2013 at 02:01 PM.
    If posting code please use code tags, see here.

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: More efficient (faster) sub-String method?

    You just have to love the multiple ways of doing things with Excel.

  5. #5
    Registered User
    Join Date
    09-16-2008
    Location
    Ottawa, Canada
    Posts
    29

    Re: More efficient (faster) sub-String method?

    Thanks to all for the quick responses.

    This has confirmed my suspisions about my working environment. I tried Mordred's code and it achieves the same results as what I had but in the same amount of time; slow. We don't use local installations of Excel on our machines at work so I am sure that is what is causing my slow processing times.

    Norie's solution works but I need to do a search&replace first to account for some exceptions but in the end it still works really fast compared to the other methods.

    Looks like I can get the 1 Hour processing time down to a few minutes.

    As always, I appreciate the help.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,584

    Re: More efficient (faster) sub-String method?

    Try this
    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)

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