+ Reply to Thread
Results 1 to 5 of 5

Split text into columns help

  1. #1
    Registered User
    Join Date
    06-04-2014
    Posts
    9

    Split text into columns help

    I am having quite a bit of a challenge here and am not able to code to split the text into columns. The text to columns does not work here unfortunately. Below is my situation. In one column that has the contract details I have the data as follows:

    Account Manager Jennifer MacFarlane CONSULTING - GENERAL on 20-JUN-13 Function #:176749
    Account Manager Janet Bewers CONSULTING - GENERAL on 25-JUL-13 Function #:176878
    Account Manager Janet Bewers HEAT STRESS AWARENESS on 27-JUN-13 Function #:176828
    Account Manager Janet Bewers TRACTOR SAFETY AWARENESS on 08-AUG-13 Function #:177383

    What do I key in to get Account Manager in one column, the name of the person in another column and the one in caps in another column and the date in one column and the function in another column. I tried using left, right and LEN and something is terribly wrong with my logic Please help.

    Thanks,

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Split text into columns help

    So, the example you gave is actually a rare one where using a space as a delimiter would work fine. You would get data in columns A:J and in column K, you could put
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , etc to gather them up. If you have more data, then I'd need to see that, because I can't tell certain things like, is there ever a middle name for the Account Manager, etc.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Split text into columns help

    With the first text string in A1:

    This in B1 will give you title:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This in C1 will give the account manager's name:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This in D1 will give the piece in capitals:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This in E1 will give the date:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and this in F1 will give the Function number:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Provided all titles are account manager (in which case I'm not sure why you need that in a separate column), there are no middle initials or names for the account managers, there are no double spaces prior to the capitalised section, that all dates are in the same format and that all function numbers are 6 characters long.
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  4. #4
    Registered User
    Join Date
    06-04-2014
    Posts
    9

    Re: Split text into columns help

    Thanks a ton gak67. this is incredible and it works. Saved a lot of time at my end. I'd really appreciate if you could explain the logic to me for each of the formulae you used as well as explain the syntax so I can learn this for future. Let me know when you have a moment.
    Thanks a ton again.

  5. #5
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Split text into columns help

    I am assuming you're familiar with the LEFT, RIGHT and LEN functions from your OP. The MID function takes the mid part of a text string from a starting position you specify and a length you specify =MID(Text string,Start position,Length).

    It then comes down to how to best identify each of the sections of the text string. The FIND and SEARCH functions give the starting position (number of characters from the left of the text string) of the text searched.

    The account manager's name was found by taking from the 17th character (with the previous 16 being "Account Mamager " including the spaces) until the 4th space from the front of the text string. Looking for the 4th instance of a space is why I said there could be no middle names or initials and no double spaces as that would mean the 4th space was not after the name. I used the SUBSTITUTE function to replace the 4th space with a character not used in the rest of the text. I chose the | character. I then used the FIND function to find the position of that character. Length of text to return is the position of the 4th space less the 16 characters of "Account Mamager " plus one for the 4th space itself, which is why there is the -17 at the end of the formula.

    The capitalised section starts from the first character after the 4th space. This is the same as the length (LEN) of the name plus the length of "Account Mamager " plus the 4th space plus 1, or simply 18+LEN(C1). I could also have used FIND("|",SUBSTITUTE(A1," ","|",4))+1 instead. The length of text to return is until 4 characters before the date (" on "). The dates all had 2 hyphens (-) separated by 3 characters, so searching for "-???-" identified it's location. You need to use the SEARCH function to use wildcard characters. The total length to return is from the start of the text string to the position "-???-", less the length of the name, less the length of "Account Mamager ", less the length of " on DD" where DD is the first 2 digits of the date, or more simply SEARCH("-???-",A1)-(24+LEN(C1)). Again there is an alternative, being SEARCH("-???-",A1)-(FIND("|",SUBSTITUTE(A1," ","|",4))+7). As I was writing this explanation I realised you could also have searched for " on " instead of "-???-". If you did that the alternatives for the lengths to use in the MID function would be FIND(" on ",A1)-(18+LEN(C1)) or FIND(" on ",A1)-(FIND("|",SUBSTITUTE(A1," ","|",4))+1).

    The date itself was again found by searching for the "-???-" and moving back 2 spaces for the DD. The length of the text to return is always nine as the format is always DD-MMM-YY, or 9 characters.

    Hopefully that makes sense to you but if you have any further questions let me know.
    Last edited by gak67; 06-05-2014 at 05:23 PM.

+ 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. Replies: 2
    Last Post: 04-09-2014, 11:48 AM
  2. [SOLVED] Split text into columns help
    By darxide23 in forum Excel General
    Replies: 11
    Last Post: 09-28-2013, 06:41 PM
  3. Replies: 4
    Last Post: 07-25-2013, 05:28 AM
  4. Split text into three columns
    By Beginner-in-VBA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2013, 03:02 PM
  5. [SOLVED] Split text without using data-text to columns
    By Jambruins in forum Excel General
    Replies: 7
    Last Post: 01-21-2006, 10:20 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