+ Reply to Thread
Results 1 to 10 of 10

Split Text to Columns over 2 Sheets

  1. #1
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Split Text to Columns over 2 Sheets

    Hello,

    I have data in Column A that is from a text file that contains 50,000 rows , this is pipe delimited data that is 300 columns wide. I would like to be able to keep the columns but using the Text to Column functions means that I lose some them.

    I was wondering if anyone knew how to separate the text in to 2 sheets, with the first 200 columns in Sheet 1 and the remaining in Sheet 2. The reason I would like to separate the information in to cells is so that I can investigate the data better.

    Its not possible to traspose this information as the rows are nearly 50,000 long.

    Here is a small sample of what 1 row is like, it not the entire row. Each "|" character represents a break and a new column.

    PHP Code: 
    A|01234567/163|01234567/163|AB123456B|Mr|Gordon|Brown|01-01-1960|1|10 Downing Street|SW1A 1AP|4|||||||||||||||||||||0|0|16-06-2009|16-06-2009|| 
    Any help is appreciated. Thanks in advance

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Split Text to Columns over 2 Sheets

    Does this work?
    Assuming data is on Sheet 1 and "|" is the delimiter


    Isolate data up to the 200th occurrence of "|" character
    =FIND(CHAR(127),SUBSTITUTE(A1,"|",CHAR(127),200))
    Copy data to Sheet 2

    Isolate remainder of the line
    =RIGHT(A1,(LEN(A1)-FIND(CHAR(127),SUBSTITUTE(A1,"|",CHAR(127),200))))
    Copy data to Sheet 3

    Then use Text to Columns on Sheet 2 and Sheet 3
    Last edited by Special-K; 09-04-2009 at 11:49 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Split Text to Columns over 2 Sheets

    Via code:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Re: Split Text to Columns over 2 Sheets

    Special-K - thank you for the formula. The second formula works fine. However when I copy the first formula in Sheet2 I get a circular reference message, when I add 'Sheet1!' before A1 in the formula I get numbers instead of the data needed.

    shg- thanks for the code. When I run this code I get '#VALUE!' in the cells where the data was and the same in Sheet2 where the data should be, Sheet 3 remains blank completely. I also get 'Run time errror '1004': Application defined or object defined', and the following line is highlighted ;-

    PHP Code: 
    With .Cells(iRow).Resize(nRow
    Also the data contains quite a few zeros which I need to keep, for example a reference number like '01234567' or some data contains multiple zeros but excel reduces this to one zero.

    I need to be able to keep the data as it is, but when doing text to column it can take a long time going through each column and specifying whether it is text, date or general. This is made even more difficult as row vary in length and the data appears in different positions.

    Thanks
    Last edited by Hblbs; 09-08-2009 at 05:07 AM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Split Text to Columns over 2 Sheets

    My Evaluate approach won't work with long strings. If SpecialK doesn't sort the fomula approach, can you post a meaningful sample of data for test?

  6. #6
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Re: Split Text to Columns over 2 Sheets

    shg - please see attached, I've taken all the personal information off, but the data is in the format that I receive it.

    Thanks
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Re: Split Text to Columns over 2 Sheets

    Bump to see if there is any takers on this.

    Thanks

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Split Text to Columns over 2 Sheets

    Try this:
    Please Login or Register  to view this content.
    Last edited by shg; 09-16-2009 at 02:54 PM.

  9. #9
    Registered User
    Join Date
    09-24-2008
    Location
    UK
    Posts
    75

    Re: Split Text to Columns over 2 Sheets

    Sorry about the late reply, thank you very much for the code.

    Yes this does separate all the data in to individual columns, the only thing I can find that is a problem is that if there are a string of 0's than this gets reduced to a single 0. Similarly if a number begins with 0 than this is cut off.

    Maybe this is a feature of Excel, but I would like to keep the data as it is. For example in Sheet2 columns AS,AT and AU have the 0’s that is missing from the original data.

    Is there a way that this can be solved?

    Thanks

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Split Text to Columns over 2 Sheets

    Try this:
    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)

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