+ Reply to Thread
Results 1 to 27 of 27

String Split to Columns

  1. #1
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    String Split to Columns

    I have a Table with Columns : A B C D E F
    In Column A I have this Strings like : B1 C2 D7 E4 F9 or C7 F20 ...
    How can I Split these String to "correct" Column ?
    For example C7 F20 string, I want in Column C to be 7 and in Column F to be 20, the rest empty
    Or Aaaa Dzzz, in Column A to be aaa and in Column D to be zzz, the rest empty.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    Clear as mud...

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    I have attached the file
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    OK. In B2, copied across and down:

    =IFERROR(LOOKUP(10^10,--MID($A2,FIND(B$1,$A2)+1,{1,2,3,4,5})),"")
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    Super !!!
    Could you explain .....{1,2,3,4,5} ? Number of columns !?!?

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    Take the example of what happens in cell D4.

    A4 B9 C2 D1 E1 F2


    the formula looks for the position of C (the 7th character) and starts from the 8th character (the +1). It then assembles an array of strings: the first with 1 character, the second with 2, and so on. The first is (minus the "") "2". the second is "2 " the third "2 D" and so on. One of the properties of the LOOKUP function is that it will return the last number it sees. That will be "2". The -- returns 2 as a number (as MID returns text that looks like a number).

    Clear as mud??? To coin a phrase...

    Thanks for the rep.

  7. #7
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    Understood, thanks but ....
    I found that I can have this situation : A4 A7 B9 C2 C11 D1 E1 F2
    So now I want in A to be 4,7 ......and in C to be 2,11

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    What is the MAXIMUM number of repetitions of any letter that can occur? I suspect that you'll need VBA for this....

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    I have found a way... providing that the maximum number, requested above, is small....

  10. #10
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    Max 5.
    Also, because probably of "" (at the end of formula) or I am not sure, when I count the the column cells, it count all lines even there is no data in cells
    I use countif(range,"")

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    I have no idea what this means "Also, because probably of "" (at the end of formula) or I am not sure, when I count the the column cells, it count all lines even there is no data in cells
    I use countif(range,"")"

    try this.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: String Split to Columns

    This is likely much simpler to do via a macro. However I have worked out a formula that works with the following considerations:
    • The string always follows the syntax of Alpha and 1 or 2 digit number then a space
    • The repeated alpha sequences are consecutive within the string (IE: "A1 A2 A3 B1 C1", NOT "A1 B1 A2 C1 A3")

    For my approach its doesnt matter how many times it repeats within a given string nor does it matter across the columns how many different strings you will look for (for ex A-F and A-Z should work with the same formula, as long as your layout is like it was in the sample).

    I had to us a couple named ranges otherwise the formula would be super long due to repeated use of the same formula/results within other formulas. See name manager. I did this on Sheet2, left your sheet1 alone for comparison.

    Hopefully it meets your needs.
    Attached Files Attached Files
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  13. #13
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    DOWNLOADED, TESTED, LIKED, BUT NOT GOOD...

    'syntax of Alpha and 1 or 2 digit number then a space' NOT GOOD,I NEED MORE DIGITS, PROBABLY MAX 4 OR 5

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: String Split to Columns

    Who are you talking to?

  15. #15
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    With Zer0Cool.

    But with you, Glenn, what you gaveme is super....

    Could you do this : A01 to be 01 and not 1 ?
    And at the bottom of any column, could you Count only the cells in that column with value ?
    Thanks again

  16. #16
    Spammer
    Join Date
    01-08-2015
    Location
    Cali, Colombia
    MS-Off Ver
    365
    Posts
    302

    Re: String Split to Columns

    Hi, to all!

    If you have this cover:
    Quote Originally Posted by Zer0Cool View Post
    • The repeated alpha sequences are consecutive within the string (IE: "A1 A2 A3 B1 C1", NOT "A1 B1 A2 C1 A3")
    You can use this formula:
    [B2] : =IFERROR(SUBSTITUTE(SUBSTITUTE(MID($A2,FIND(B$1,$A2),FIND(" ",$A2&" ",FIND("|",SUBSTITUTE($A2,B$1,"|",LEN($A2)-LEN(SUBSTITUTE($A2,B$1,"")))))-FIND(B$1,$A2)),B$1,"")," ",", "),"")

    Check file. Blessings!
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    johnmpl, your file works very well, and is simple

  18. #18
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    I can not count the cells with text only.
    For example, in ExtractNumbers.xlsx (attached file above) if a want to count cells with text/value in column using count(column_range,"*") still count all the cells

  19. #19
    Spammer
    Join Date
    01-08-2015
    Location
    Cali, Colombia
    MS-Off Ver
    365
    Posts
    302

    Re: String Split to Columns

    Quote Originally Posted by ionelz View Post
    if a want to count cells with text/value in column using count(column_range,"*") still count all the cells
    Use:
    =COUNTIF(B2:G2,"?*")
    or
    =COUNTIF(B2:G2,"><0")

    Blessings!

  20. #20
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    This is crazy question
    In the file : ExtractNumbers.xlsx (attached file above) is anyway to UPDATE back the STRING if any modification in columns ?
    So for example in cell A2B2 if I change from 1 to 6 can I get in an updated String to A6 C2 F5 ?

  21. #21
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    or Create another Column, String1 and concatenate back the columns A ..F to String1 column

  22. #22
    Spammer
    Join Date
    01-08-2015
    Location
    Cali, Colombia
    MS-Off Ver
    365
    Posts
    302

    Re: String Split to Columns

    Quote Originally Posted by ionelz View Post
    This is crazy question
    In the file : ExtractNumbers.xlsx (attached file above) is anyway to UPDATE back the STRING if any modification in columns ?
    So for example in cell A2B2 if I change from 1 to 6 can I get in an updated String to A6 C2 F5 ?
    This is possible with VBA, because in a cell you can have a value or a formula, not both.

    Quote Originally Posted by ionelz View Post
    or Create another Column, String1 and concatenate back the columns A ..F to String1 column
    Try, for example:
    =TRIM(IF(B2="","",SUBSTITUTE(", "&B2,", "," "&B$1))&IF(C2="","",SUBSTITUTE(", "&C2,", "," "&C$1))&IF(D2="","",SUBSTITUTE(", "&D2,", "," "&D$1))&IF(E2="","",SUBSTITUTE(", "&E2,", "," "&E$1))&IF(F2="","",SUBSTITUTE(", "&F2,", "," "&F$1))&IF(G2="","",SUBSTITUTE(", "&G2,", "," "&G$1)))

    Blessings!
    Last edited by johnmpl; 01-12-2018 at 11:01 PM.

  23. #23
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    I have added a new Table 2 to the File, see attached.
    I would like to COMPARE Column A from Table 1 with Column A from Table 2 and put the result in Table 1 Column A Meaning
    01. If Table CELL in 1 Column A = CELL Table 2 Column A say A Meaning from Table 2 otherwise say "Invalid"
    02. If in Table 1 Column A is a "String" (like see in Table 1 "4,7,5") , here without comparation simple say "Text 2"
    Thanks
    Attached Files Attached Files

  24. #24
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    01. If CELL Table 1 Column A =

  25. #25
    Forum Contributor
    Join Date
    05-20-2016
    Location
    Detroit
    MS-Off Ver
    Office 365 Version 2008 (July 2020)
    Posts
    819

    Re: String Split to Columns

    Could you PLEASE update the Formula you wrote in attached file, if possible ?
    You wrote the Formula for Maximum 5 Repetition and Work Great.
    But now I know that, ONLY ONE in String can have Multiple repetitions (named always G) the rest are unique.
    Will this make the Formula simple ?
    Also, I have added Cell A9
    Can the Formula look in String until Character * ? (so ONLY in the LEFT side of * and Ignore the String in the Right side of star)
    Thank You


    Quote Originally Posted by Glenn Kennedy View Post
    I have no idea what this means "Also, because probably of "" (at the end of formula) or I am not sure, when I count the the column cells, it count all lines even there is no data in cells
    I use countif(range,"")"

    try this.
    Attached Files Attached Files

  26. #26
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: String Split to Columns


  27. #27
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: String Split to Columns

    Already mentioned

+ 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. Formula(s) to Split Text String Across Columns Using Columns as Seperator
    By WaylettChris in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-24-2016, 01:13 PM
  2. split string into multiple columns
    By bmccall17 in forum Excel General
    Replies: 8
    Last Post: 06-05-2015, 12:27 AM
  3. [SOLVED] Split String at every "/" then put split string results into a multiline textbox.
    By Andrew Andromeda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2015, 01:49 AM
  4. [SOLVED] complex split string (delimit-text to columns)
    By EXLwiz in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-09-2014, 09:59 AM
  5. [SOLVED] Split text string into 5 columns
    By Desree86 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-14-2014, 10:07 AM
  6. Split String into many columns according to Format criteria
    By wali in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-23-2010, 01:50 AM
  7. Split text string to different columns
    By liarliar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2008, 09:13 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