+ Reply to Thread
Results 1 to 8 of 8

splitting one cell into multiple rows (and retaining all other data from other columns)

  1. #1
    Registered User
    Join Date
    07-08-2019
    Location
    Hillsboro, Oregon
    MS-Off Ver
    365
    Posts
    34

    splitting one cell into multiple rows (and retaining all other data from other columns)

    Hello All,

    I frequently come here to view other responses but actually truly needed some help that I couldn't find a definite answer/solution for through my browsing. In short, I have a spreadsheet (10,000+ rows) with one column in particular that I need to split the values in there into multiple rows which retain the data from the other columns in that same row as the current format is basically #####, #####, #####, etc. Only the data in column E needs to be parsed out...

    cells to split.jpg

    Is this at all possible? If column A's first row (row 2) had a value of ABCDEF and I wanted to split column B into multiple rows based on the values in the cell separated by commas (example: 123, 456, 7890, etc.), how can this be done? FYI - there are other columns as I noted before that do not need to be split up and can retain the same data they already hold into the new row(s).

    Thank you so much!

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    I am not sure what you are trying to do, but try this on a copy of your file or a mock up and see if it does what you want.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    07-08-2019
    Location
    Hillsboro, Oregon
    MS-Off Ver
    365
    Posts
    34

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    Thank you very much for the response - this is definitely taking me in the right direction! I'm not so great with the VB code at times, and the ability to insert an entire row is new to me.
    Again, thank you. Basically, you have the right idea of what I want to achieve but there is one thing missing. See below image for reference.

    cells to split 2.jpg

    I also wanted to copy all the other values in the other columns for that row into the new row once the data is split. So wherever data in column D (in this screenshot) or any of the other columns exist, I wanted that to be copied down into the newly created rows. Is that possible? Would that be including something additional in the VB code you provided before?

    Thank you again.
    Last edited by ckhan84; 07-08-2019 at 06:40 PM.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    I thought you might want that, but wanted to make sure I understood the OP first.

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 07-09-2019 at 07:37 AM.

  5. #5
    Registered User
    Join Date
    07-08-2019
    Location
    Hillsboro, Oregon
    MS-Off Ver
    365
    Posts
    34

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    Thank you!!! This is exactly what I needed and thoroughly appreciate your help as I wouldn't have been able to figure some of this out without extra help. I am typically working with this data in a PivotTable and this is why I needed the data like this which is easier to work with.

    I do have one final additional question as scenarios can come up where I have data like what was in column E also in other columns that need to be split and "matched up" with respective data from the other columns. For example:

    cells to split 3.jpg

    How would I modify the last set of VB code that you provided in order to also parse out additional columns. In this example, this would be columns E, F, and G. Again, what is in column E needs to be matched with what was exported in F and G from the system that outputs this. This is probably far more complicated, but if it is possible, I'd really appreciate the direction as this may come up at some point.

    Major thanks again for your assistance and expertise!
    Last edited by ckhan84; 07-09-2019 at 10:35 AM.

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    It would be easier to work with if you would upload your file or a facimile of the file. You can do that by clicking 'Go Advanced' at the bottom of the reply input box, Then click 'Manage Attachments' and follow the options menu. In general, the Split function creates an array and you can use either the comma (","r Space (" ") as delimiters, based on how the data is entered into the cells. Then to make it paste vertically, use the Application.Transpose function. The array is zero based so LBound - 0 and UBound will = one less than the number of items in the array. The 'For i' statement then uses the LBound and UBound integer values to set the number of rows by resizing from and anchor cell or range. It is all a matter of simple math once you understand where the numbers come from and how to use them with the Offset and Resize methods..

  7. #7
    Registered User
    Join Date
    07-08-2019
    Location
    Hillsboro, Oregon
    MS-Off Ver
    365
    Posts
    34

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    Thank you for your continued support. I have attached a sample of the file and removed some of the more sensitive data or replaced data with placeholder numbers for now.

    This would still capture what I would likely need to work with in the future. Basically, I have column A that needs to be "copied down" when data in columns B, C, and D are split. I also added in a column E titled "comments" with just junk data as this would likely represent another column that I would just need "copied down" into added rows for the split data. Please let me know if this makes sense and what code you would use in a scenario like this.

    Thanks again!
    Attached Files Attached Files

  8. #8
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: splitting one cell into multiple rows (and retaining all other data from other columns

    From the data provided, it appears that there will always be the same number of items in each cell for columns B, C and D. If this holds true, then only one cell per row will need to be used for numerical purposes of Offset and Resizing to add rows and populate them.. If there was a disparity in the count of items between the three columns using arrays, then it would be more complex.

    Please Login or Register  to view this content.
    This takes a few seconds to run because of the looping, but it should not take more than a minute.
    Last edited by JLGWhiz; 07-10-2019 at 08:38 AM.

+ 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. [SOLVED] Splitting data in cell to multiple columns
    By Nordin1980 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 06-03-2017, 10:27 AM
  2. [SOLVED] Splitting 2000 rows of data into multiple columns
    By DHFE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2016, 05:52 AM
  3. Replies: 14
    Last Post: 08-20-2014, 05:46 AM
  4. Splitting an Excel File into Multiple Sheets but retaining lookup data etc
    By PhilTSmith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2013, 11:05 AM
  5. Replies: 7
    Last Post: 08-16-2010, 11:48 AM
  6. Splitting data from a cell to multiple rows
    By mukul.saxena in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-27-2009, 02:09 AM
  7. Splitting columns by , and retaining orginal row information
    By tjquinn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2008, 08:11 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