+ Reply to Thread
Results 1 to 5 of 5

Please Help - split a string having both comma (,) and semicolon(;)

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    Delhi
    MS-Off Ver
    Excel 2003
    Posts
    1

    Unhappy Please Help - split a string having both comma (,) and semicolon(;)

    Hi,

    I need the function required to split the string seperated by both the Comma(,) and Semicolon(";"). Also please note that few of the segments can also have data in brackets seperated by comma(,) which shold not be split.

    String - (Jan--01/Jun--30;EXPO(2000),July--01/Dec--31;NORM(100,200),.....)

    Output -
    date = Jan--01/Jun--30
    data1 = EXPO(2000)
    date2 = July--01/Dec--31
    data 2 = NORM(100,200) ---> the numbers within bracets should not be split.

    Thanks.
    Chandan

  2. #2
    Registered User
    Join Date
    06-20-2012
    Location
    Melbourne Australia
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: Please Help - split a string having both comma (,) and semicolon(;)

    Hello Chandan,

    Try the following formulae if the string is in A1.
    The first date =MID(A1,2,FIND(";",A1,1)-2)
    data1 =MID(A1,FIND(";",A1,1)+1,FIND(",",A1,B1)-FIND(";",A1,1)-1)
    date2 =MID(A1,FIND(",",A1,FIND(";",A1,1))+1,FIND(";",A1,FIND(",",A1,FIND(";",A1,1))+1)-FIND(",",A1,FIND(";",A1,1))-1)
    data2 =MID(A1,F1+1,FIND(",",A1,FIND(";",A1,1)+1))

    Cheers,
    Diana

    If I've helped, click on the star to the left.

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Please Help - split a string having both comma (,) and semicolon(;)

    Hi
    this should do it by macro, if you prefer - you will need to set the input and output cells, and make sure the replace function uses a character you'll never have in your string (Where I used "@")

    Please Login or Register  to view this content.
    Last edited by NickyC; 07-05-2012 at 03:44 AM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Please Help - split a string having both comma (,) and semicolon(;)

    Hello Chandan.jh,

    Welcome to the Forum!

    You gave only one example of the data you want to separate. You did not say whether the output would vertical (rows) or Horizontal (columns). This macro will correctly parse any text string according to your rules and output the results either vertically (the default) or horizontally to the cell of your choice.

    The OutputDirection is optional. You can use one of two Excel built-in constants: xlByRows or xlByColumns. If you do not specify one of the constants then the default is by rows.
    Please Login or Register  to view this content.
    Here is an example of using the macro. The Text is on "Sheet2" cell "A1". The output is going to "Sheet1" cell "B1". All parsed data will start in "B1" and move across to "C1", "D1", etc.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: Please Help - split a string having both comma (,) and semicolon(;)

    try
    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)

Tags for this Thread

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