+ Reply to Thread
Results 1 to 21 of 21

Split strings based on numbers and gather scattered strings

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Split strings based on numbers and gather scattered strings

    Hello everyone
    I have in column A some strings separated by numbers ..
    I need to put each string which ends with number in separated row
    In fact it is difficult to describe the required but I have attached a sample workbook to illustrate the desired results
    Thanks advanced for help
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Split strings based on numbers and gather scattered strings

    Hi there Yasser!
    My code takes advantage from RegEx so you'll need to add the referece for it. Tools -> References Find Microsoft VBScript Regular Expressions 5.5 in the list and tick the checkbox next to it. Click OK.
    Here is the used code:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Thanks a lot Mr. Bogdan for this wonderful solution ...
    It is working exactly as I need .. thanks a lot

    What If I have specific string and I need to exclude from results
    I mean if the cell starts with specific string so tis row to be excluded
    For example my string is "Yasser" if the cell starts with this string , so this row to be excluded fro results completely
    Hope this doesn't disturb you

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Split strings based on numbers and gather scattered strings

    Please Login or Register  to view this content.

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

    Re: Split strings based on numbers and gather scattered strings

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Split strings based on numbers and gather scattered strings

    Thank you for jumping in Jindon. Your code seems more accurate. Always something to learn from you.

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

    Re: Split strings based on numbers and gather scattered strings

    You are welcome.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Thanks a lot Mr. Bogdan for your great help
    Thank you very much Mr. Jindon the Great Tutor for your incredible solutions in all issues
    Best Regards

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

    Re: Split strings based on numbers and gather scattered strings

    You are welcome and thanks for the rep.

    bulina2k,

    To understand most efficient pattern in Regular Expressions needs practice, and unfortunately there is almost no web site that describe in details for many situations...

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Sorry for disturbing you again Mr. Jindon
    I have encountered in my data new point

    Related to the text to be excluded .. I don't need to exclude it if the same cell has a number ..
    I mean if cell has "Yasser" at the beginning of the cell only and no numbers in this cell so this would be excluded
    But if "Yasser" at the beginning of the cell and the cell has number in it so this cell would NOT be excluded ...
    Sorry for disturbing as my original data may encounter new instances

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

    Re: Split strings based on numbers and gather scattered strings

    Upload a workbook with your desired result.

  12. #12
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Split strings based on numbers and gather scattered strings

    Quote Originally Posted by jindon View Post
    bulina2k,

    To understand most efficient pattern in Regular Expressions needs practice, and unfortunately there is almost no web site that describe in details for many situations...
    Yes you are right, I'm at the dawn of the RegEx solutions, but I can say I find them fascinating. The helping site I use is https://regex101.com/

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Here's another sample
    Attached Files Attached Files

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

    Re: Split strings based on numbers and gather scattered strings

    For the workbook uploaded.
    Please Login or Register  to view this content.
    For the Arabic, see if this works.
    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    That's incredible
    I can't believe myself. I am in a happy dream
    Really fascinating and working like charm

    As for Arabic this is a very good step .. just one little point ..
    Which is the string (Arabic string) to be excluded from the process unless it has a number ..

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

    Re: Split strings based on numbers and gather scattered strings

    Use one on the top and try change to
    Please Login or Register  to view this content.
    and see if this works.

  17. #17
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Thanks a lot Mr. Jindon for this wonderful and great code
    Is it possible to use regex patterns with arrays ..as arrays as I know is faster
    In original file the code works fine .. of course I changed 100 to 20000 to get all the results
    Please Login or Register  to view this content.
    but it took about five minutes .. at the end it is fascinating in results .
    I am searching now to get it executed faster ...
    Thanks again for help and if you stopped at this point I won't be disappointed as I got incredible help from you
    Best and kind regards
    Last edited by YasserKhalil; 04-10-2016 at 08:13 PM.

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

    Re: Split strings based on numbers and gather scattered strings

    Please Login or Register  to view this content.

  19. #19
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    Thanks again and again Mr. Jindon
    But it seems to have the same period .. or less a little..
    Don't tire yourself .. everything is ok now and I can wait four or five minutes .. Never mind about that
    Thank you very much
    Best and Kind Regards

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

    Re: Split strings based on numbers and gather scattered strings

    Since you have 200000 rows, the length of the string could be incredibly long.
    And if number matching string is also many, it will take time regardless of use Array.

    It is not the outputting time, but data processing time, so no control.

  21. #21
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Split strings based on numbers and gather scattered strings

    I have said 20,000 not 200,000 ..
    Generally I am very satisfied with the solution you provided ..which is the following code
    Please Login or Register  to view this content.
    And as for the string that I need to exclude I could cure it through another macro ...
    Thanks a lot for great contribution in this thread

+ 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 to Delete only Alpha Strings but not Alphanumeric or Numeric Strings in a Cell
    By papageorgio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 06:55 AM
  2. [SOLVED] Loop through strings stop when strings change and start looping in the next column...?
    By Prexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2013, 03:31 AM
  3. Split Strings Into Columns Based On Repeating Characters - Macro
    By jessekanclerz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2013, 11:13 AM
  4. Replies: 1
    Last Post: 08-13-2013, 08:32 AM
  5. Replies: 2
    Last Post: 03-07-2013, 02:34 AM
  6. Replies: 5
    Last Post: 02-15-2012, 09:57 AM
  7. Replies: 3
    Last Post: 05-28-2011, 01:43 PM

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