+ Reply to Thread
Results 1 to 9 of 9

Split Cell content

  1. #1
    Registered User
    Join Date
    07-15-2014
    Location
    London
    MS-Off Ver
    Office 2010
    Posts
    22

    Split Cell content

    Hi,

    I am looking for some assistance to split a cell content which are separated by comma's into respective columns. Though I manage to get that partially work but another hand would be helpful.
    Attached Files Attached Files
    Last edited by Funtooskool; 03-28-2016 at 07:16 PM.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Split Cell content

    please see if this macro works for you..

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-15-2014
    Location
    London
    MS-Off Ver
    Office 2010
    Posts
    22

    Re: Split Cell content

    Hey rcm,

    Thanks for the response, you are quite close to what I am looking for however the first column 'Ref#' should also reflect in respecting columns.

    expected output

    Ref# Source Destination
    1 1.1.1.1 3.3.3.3
    1 2.2.2.2 3.3.3.3
    2 4.4.4.4 5.5.5.5
    2 4.4.4.4 6.6.6.6
    3 7.7.7.7 8.8.8.8
    3 7.7.7.7 9.9.9.9
    3 7.7.7.7 10.10.10.10

    Cheers
    FUN

  4. #4
    Registered User
    Join Date
    07-15-2014
    Location
    London
    MS-Off Ver
    Office 2010
    Posts
    22

    Re: Split Cell content

    Hi,

    Its seems number of rows are hard coded, that was just sample data, there could be many rows of data like that.

    Cheers
    Shaikh

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Split Cell content

    Updated to show Ref#


    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-15-2014
    Location
    London
    MS-Off Ver
    Office 2010
    Posts
    22

    Re: Split Cell content

    Hey JohnTopley

    that work !! would you be able to incorporate additional column as below

    Rule Ref # Source IP Destination IP Port
    1 | "1.1.1.1,
    | 2.2.2.2," 3.3.3.3 10065, 12050, 12051
    2 | 4.4.4.4 "5.5.5.5,
    6.6.6.6" 30001, 32002



    Expected output
    Rule Ref # Source IP Destination IP Port
    1 1.1.1.1 3.3.3.3 10065
    1 1.1.1.1 3.3.3.3 12050
    1 1.1.1.1 3.3.3.3 12051
    1 2.2.2.2 3.3.3.3 10065
    1 2.2.2.2 3.3.3.3 12050
    1 2.2.2.2 3.3.3.3 12051
    2 4.4.4.4 5.5.5.5 30001
    2 4.4.4.4 5.5.5.5 30001
    2 4.4.4.4 6.6.6.6 32002
    2 4.4.4.4 6.6.6.6 32002

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Split Cell content

    try this ..

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-23-2016
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    1

    Re: Split Cell content

    Hi,

    Have you thought at using Power Query, an add-on to Excel? It is the ideal tool to deal with that type of problems.
    It has a tool to split a column into many separate columns by specifying a delimiter. You can do this at a specific occurence of the delimeter or all occurences.

    Below the details of it all. It looks complex, best is perhaps to print and just follow the instructions. It is actually really simple once you understand how Power Query works. Before you know it, you could get addicted .

    In a nutshell, search the web on how to install Power Query (it is free)

    Highlight your data (range A1:C4)
    On the Power Query tab that is now in Excel, click the "From Table button". This opens the editor

    Select the "source" column, then, on the Home tab, click the "Split By" button. Select comma as the delimiter and "at each occurence of the delimiter"
    This creates a second "source" column.

    We now unpivot the two. Select the two source columns, on the Transform tab, click "Unpivot columns". Remove the column called "Attributes" (right click and remove). Rename the column "Value" into "Source"

    Now select the destination column and do a split by again, comma as delimeter, at each occurence. It will create as many columns as separators.

    Now we need to unpivot the "destination" columns. Since we do not know how many there could potentially be, we do the unpivot slightly differently. We do NOt select the "destination" columns, instead, select the other two columns which should be "Ref" and "source". Then go to Transform Tab, open the drop-down of the unpivot columns tool and select the option "unpivot all othr columns"

    Some more cleaning: remove the attribute column which is not needed anymore and rename the "value" column into "destination".

    Home tab --> save and load.

    And that's it! You have just created a query that you can easily reuse next time you have to do this job again. It will also teach you some basics of this jewel tool that is Power Query

    Cheers,
    Christine

  9. #9
    Registered User
    Join Date
    07-15-2014
    Location
    London
    MS-Off Ver
    Office 2010
    Posts
    22

    Re: Split Cell content

    Thanks JohnToPlay,

+ 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: 7
    Last Post: 08-12-2014, 10:40 AM
  2. Split Cell content to rows
    By Cunner in forum Excel General
    Replies: 5
    Last Post: 08-14-2013, 08:55 AM
  3. split cell content using VBA
    By leonv01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2012, 09:05 AM
  4. Replies: 4
    Last Post: 02-05-2012, 02:11 PM
  5. Split cell content after specific character
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-04-2011, 01:33 AM
  6. Split content in cell
    By acampos in forum Excel General
    Replies: 1
    Last Post: 08-19-2009, 11:56 AM
  7. Split Cell content in multiple cells
    By pomolo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-28-2008, 07:10 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