+ Reply to Thread
Results 1 to 22 of 22

Split text from cell

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Split text from cell

    Hi Guys,

    I have cell with a lof of values like:

    Screenshot_19.png

    I want to take pairs and get 2 columns result for each of them.

    Screenshot_20.png

    Please also find sample workbook.

    Please help,

    Best,
    Jacek
    Attached Files Attached Files

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

    Re: Split text from cell

    Adjust the output.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    Wow awesome,

    thank you!
    Jindon i can not decode how this pattern is working.

    * - matching preceding element
    [] - any signs between brackets
    \u = what is it ?
    00 = ??
    A = ??
    0 = ??

    Please help,
    Best,
    Jacek

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

    Re: Split text from cell

    Actually pattern is simply
    Please Login or Register  to view this content.
    Your space is "Non-break-space" which is ChrW(160) and the unicode is U+00A0.
    In regexp, you can have unicode after \u.
    So it means space(s) or non space with "non-breake-space" followed by space(s) or none space.
    The code replaces such group to Chr(2).

    Understand?
    Last edited by jindon; 09-06-2018 at 09:33 AM.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Split text from cell

    Perhaps next code more at the human level
    If you want to loop explain the data lay out
    Please Login or Register  to view this content.
    Last edited by PCI; 09-06-2018 at 01:17 PM.
    - Battle without fear gives no glory - Just try

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,483

    Re: Split text from cell

    @ PCI
    Perhaps next code more at the human level
    Yeah, I agree ... jindon is not "OF THIS WORLD" one can only aspire ...
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    Hi Guys,

    sorry for my late answer.

    Jindon is not of this world but i love his macros and learning from him. What he learned me (like array lists and dictionary within dictionary) i am using now

    PCI thank you, what is chr 160? Non breaking space ? it is like a lot of spaces?

    I = 1: J = 1
    what does it mean?

    Jindon

    Understand?
    not exactly. So this code: U+00A0 is non breaking space here? (chr160)?

    ( *
    what each element mean here?

    +
    what does it mean?

    So it means space(s) or non space with "non-breake-space" followed by space(s) or none space.
    Hmm which element is for what?

    Thank you!
    Best,
    Jacek

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

    Re: Split text from cell

    " *\u00A0 *" = equivalent to " *" & ChrW(160) & " *" as \u00A0 = ChrW(160) which is non breaking space.
    When character(s) are are within a brackets, it is a character group.
    ( *\u00A0 *)+ and the last + means 1 or more consecutive preceding character/character set.
    So that it matches to the big space within you string.

    You can see the result in msgbox when it replaces like this.
    As chr(2) is not printable, so used "@" instead.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    thank you Jindon very much!

    it is clear now.

    Best,
    Jacek

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Split text from cell

    what is chr 160
    This the character separator used between text: 160 is the ASCII code

    I = 1: J = 1
    I equal 1 and J equal 1, the ":" permits to "stick" statement on the same line

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    a nice !

    thank you PCI

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Split text from cell

    You are welcome, we are here to learn and to share
    Last edited by PCI; 09-09-2018 at 03:44 AM.

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

    Re: Split text from cell

    Quote Originally Posted by jaryszek View Post
    thank you Jindon very much!

    it is clear now.

    Best,
    Jacek
    Glad you understand and thanks for the rep.
    Yes, we share the idea, but not to steal like someone does...

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Last edited by jindon; 09-08-2018 at 11:45 PM.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    Hi Guys,

    i have new data. What pattern should i have using object:

    Please Login or Register  to view this content.
    to split the text?

    In attachment sample workbook.
    Thank you,
    Best,
    Jacek

    Screenshot_29.png
    Attached Files Attached Files
    Last edited by jaryszek; 09-24-2018 at 11:29 AM.

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

    Re: Split text from cell

    No idea..............

  16. #16
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    jindon,

    why ?

    Best,
    Jacek

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

    Re: Split text from cell

    How do you convert data in Sheet2 to format in result sheet for yourself?

  18. #18
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    aaa no no,

    i only want to split cell A1 like you did in first case.

    So result should be:
    DAL09 - Dallas first row
    Dal10 - Dallas second row etc.

    Best,
    Jacek

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

    Re: Split text from cell

    The no need of Regular Expressions.
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    thank you very much jindon.

    why did you use trim with $ ?

    Best,
    Jacek

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

    Re: Split text from cell

    While you are in vbe, got to [view] - [Object Browser]
    Enter trim$ in serach dropdown.

    You will see functions that has $ and without $.

    If you click on Trim, it says Function Trim(String)
    while Trim$, Function Trim$(String As String) As String

    Means function with $ returns string type explicitly, and said it would be a bit faster.

  22. #22
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,942

    Re: Split text from cell

    thank you !

    Nice explanation !

    Best,
    Jacek

+ 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. Too Much text in Cell!! Split using VBA
    By mnadamn19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2017, 10:21 PM
  2. [SOLVED] Text in a Split Cell
    By Pete291 in forum Excel General
    Replies: 4
    Last Post: 12-02-2016, 12:36 PM
  3. Replies: 4
    Last Post: 11-11-2015, 03:00 PM
  4. Split text into different cell
    By Allmaths in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2015, 06:03 AM
  5. [SOLVED] Split text in a cell
    By dougmorgan in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-23-2013, 12:48 PM
  6. split text from one cell
    By duda in forum Excel General
    Replies: 5
    Last Post: 01-17-2011, 04:40 PM
  7. Split text to next cell down
    By drawing.blanks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2009, 03:31 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