+ Reply to Thread
Results 1 to 4 of 4

Problems Splitting String into Chunks

  1. #1
    Registered User
    Join Date
    03-29-2020
    Location
    Toronto, Ontario
    MS-Off Ver
    2016
    Posts
    2

    Problems Splitting String into Chunks

    Hi all,

    I have a spreadsheet with many string entries that contain text in the following format: PhaseName, SubphaseName, Subphase2Name.

    The problem is the various string portions are delineated by multiple spaces and the number of spaces is not consistent. For example, in some cases the number of spaces between the PhaseName and SubphaseName is 14 while the number of spaces between SubphaseName and SUbphase2Name might be 5.

    I would like to split the original string into three columns as shown in the attached spreadsheet.

    Your help would be greatly appreciated.

    Thank you very much!
    Attached Files Attached Files
    Last edited by garvizu; 03-29-2020 at 12:55 PM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Problems Splitting String into Chunks

    Actually, the sections are delimited by carriage returns.

    Try this:

    1) select the data column
    2) replace all double-spaces with nothing
    (That will do most of the clean up)


    3) Data.Text-to-columns
    --Delimited....Click: Next
    --Select the "Other" box
    --Press CTRL+j (that will put the carriage return in the box)
    --Click: Finish

    There will only be minor clean up left.

    Or...If you want to use formulas
    Put this regular formula in B2 and copy across through D2 and down as far as you need:
    =TRIM(MID(SUBSTITUTE($A2,CHAR(10),REPT(" ",LEN($A2))),(COLUMNS($B:B)-1)*LEN($A2)+1,LEN($A2)))

    Note: THe ASCII code for a carriate return is 10.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    03-29-2020
    Location
    Toronto, Ontario
    MS-Off Ver
    2016
    Posts
    2

    Re: Problems Splitting String into Chunks

    Wow! It took you minutes what has been bugging me for hours.

    Thank you very much!

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Problems Splitting String into Chunks

    Glad you got something you can use!

    If that resolves your issue, please take a moment to mark this thread as SOLVED (from the Thread Tools menu)

+ 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. Splitting up a String
    By Zahed in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2019, 12:14 AM
  2. Replies: 3
    Last Post: 10-21-2016, 07:46 PM
  3. [SOLVED] Splitting a 24k Rows Worksheet into Smaller Chunks
    By woodsonline in forum Excel General
    Replies: 10
    Last Post: 10-18-2012, 06:02 PM
  4. String Splitting Problems with VBA,
    By Irish RayRay in forum Excel General
    Replies: 4
    Last Post: 03-16-2012, 11:07 AM
  5. Problems splitting a text & number string using VBA
    By Tamor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2009, 11:03 AM
  6. [SOLVED] Splitting a text string into string and number
    By mcambrose in forum Excel General
    Replies: 4
    Last Post: 02-21-2006, 11:50 AM
  7. Splitting text document into chunks of 100 characters
    By Chris.Holland16@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2006, 04:00 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