+ Reply to Thread
Results 1 to 12 of 12

split comma separated names in a column to a new column

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Question split comma separated names in a column to a new column

    Hello,

    I am working on this spreadsheet that has a list of tasks assigned to resources and schedules. Some of the tasks have multiple people assigned to them, I am trying to split the names so that they can be associated with the individual task, but if there are more that one people assigned to the task, I just want to know who else is also associated with that task.

    There are 2 worksheets in the attached workbook,
    Input: has the data that is exported by an application, the format will not change, the number of rows will depending on the project and tasks, the names will always be comma separated in the format, FirstName LastName, FirstName LastName. (the second set will only be there if there is more than 1 person assigned to a task)
    Output: this is the report that I am trying to make it look like.

    I am trying to come up with a macro that will go through the "Input" worksheet and create the "Output" worksheet.

    1. Go through the names in column C and if there are more than one names present in the cell.
    2. Split each name, and create a new row under it with the first name in Column (B) "Name", but also create a new column (D) "Other Resource" and put the other names in that column and do that for all the names in the column.
    3. None of the information in other columns change, they are copied as is with the names associated with them.
    4. Go through the worksheet and do it for all the rows that have multiple names.

    If any more information is needed, please let me know. Thanks in advance, I really appreciate the help.
    Attached Files Attached Files
    Last edited by letsxcel; 11-15-2012 at 07:36 PM. Reason: edited attachment

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: split comma separated names in a column to a new column

    Hi

    Tasks!C17 has what appears to be 2 names, but they are not comma separated. Is this a typo, or is this really one name?

    rylo

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: split comma separated names in a column to a new column

    Why not just use a Pivot Table. It will give the information you want, (and much more as well)?

    Not quite in the same layout but it will take a few seconds rather than much longer to develop a macro, and be a lot more flexible.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: split comma separated names in a column to a new column

    rylo,
    It is a typo sorry about that, I updated the sheet after i realized it but forgot to upload the new worksheet, just fixed it

    Richard,
    This is actually a part of a bigger script solution. Can the Pivot Table be automated? I am not too familiar with them but I will look it up!

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: split comma separated names in a column to a new column

    Hi

    Doesn't have the pretty formatting, but I think it splits things out as you require.

    Please Login or Register  to view this content.
    rylo

  6. #6
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: split comma separated names in a column to a new column

    Rylo, This is wonderful. It's almost perfect.

    When I ran the macro, it created extra rows with only column B and C populated but all other columns are empty ( I have attached a worksheet with the results). Is there a way those can be removed? Why are they there?

    Also, it is currently sorted by column C. Can you please modify to sort it by ID (ie column A)

    Thanks a ton for this !
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: split comma separated names in a column to a new column

    Hi

    The extra rows with data in columns B and C are there because the output sheet of the file in #1 had them there. Sorting was just something I added to be able to insert the "heading" rows.

    Can you put up an example file that has both data and the EXACT order / shape for the output for that data.

    rylo

  8. #8
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: split comma separated names in a column to a new column

    Hi Rylo,

    My bad on the files. Please find attached a sample file with the input and the output sheets. Thanks a lot for your help. I really do appreciate it.
    Attached Files Attached Files
    Last edited by letsxcel; 11-16-2012 at 01:16 AM. Reason: added updated attachment

  9. #9
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: split comma separated names in a column to a new column

    as an option
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: split comma separated names in a column to a new column

    Hi Nilem, Thanks for the reply but when I run the macro I am getting an error: Runtime Error : 9 , Subscript out of range !

  11. #11
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: split comma separated names in a column to a new column

    Do you get an error with the data from your file "split_sample_file_excelforum_v3.hlsm"? Or do you use other data?

  12. #12
    Registered User
    Join Date
    10-23-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: split comma separated names in a column to a new column

    Nevermind Nilem. I figured it out. It works

    Thanks a lot for your help.
    Last edited by letsxcel; 11-16-2012 at 10:58 AM.

+ 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