+ Reply to Thread
Results 1 to 9 of 9

Split row into multiple row based on column text

  1. #1
    Registered User
    Join Date
    10-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007/10
    Posts
    43

    Split row into multiple row based on column text

    The title may be confusing, but this is what I'm looking for:

    For example, I have row 1, 2, 3. Column B in these rows contain comma separated zone codes

    A1 = Apple
    A2 = Orange
    A3 = Banana

    Ex. B1 = 152, 156, 989
    B2 = 346, 123, 123, 934, 123
    B3 = 342

    I want to separate the rows out so that each has it's own unique zone code (only one code per line)

    Final result looks like this:

    A B
    Apple 152
    Apple 156
    Apple 989
    Orange 346

    etc.

    Any ideas?

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Split row into multiple row based on column text

    Hi,

    Assuming the original table as you give it is in A1:B3, enter this array formula** in D1:

    =IFERROR(INDEX($A$1:$A$3,MATCH(TRUE,MMULT(--(ROW($A$1:$A$3)>=TRANSPOSE(ROW($A$1:$A$3))),1+LEN($B$1:$B$3)-LEN(SUBSTITUTE($B$1:$B$3,",","")))>=ROWS($1:1),0)),"")

    Copy down until you start to get blanks for the results.

    Then, in E1 (non-array):

    =IF(D1="","",TRIM(MID(SUBSTITUTE(INDEX($B$1:$B$3,MATCH(D1,$A$1:$A$3,0)),",",REPT(" ",197)),197*(COUNTIF(D$1:D1,D1)-1)+1,197)))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    10-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007/10
    Posts
    43

    Re: Split row into multiple row based on column text

    Thanks for the response---I can't seem to get the array formula right, however. Do I put it in D1, then ctrl/shift/enter? Or do I have to do them all at once from the beginning?

    Thanks!

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Split row into multiple row based on column text

    Hi again,

    Just the first. Once you've committed it correctly as per my instructions, only then should you drag it down.

    Regards

  5. #5
    Registered User
    Join Date
    10-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007/10
    Posts
    43

    Re: Split row into multiple row based on column text

    Hmm seem to get blanks for everything :/

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Split row into multiple row based on column text

    I might suggest you upload your attempt in an actual workbook then.

    Obviously replace any confidential/sensitive information with dummy data if necessary.

    Regards

  7. #7
    Registered User
    Join Date
    10-04-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007/10
    Posts
    43

    Re: Split row into multiple row based on column text

    I appreciate the patience!

    In this I'm looking at column R: there are multiple 3 digit codes in this and I want each row to have only one, therefore is there are 3 codes, the row would need to be duplicated 3 times, each with one of the three codes.

    Book1.xlsx

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Split row into multiple row based on column text

    Thanks, but where's your attempt at adapting the formula I posted in this book?

    Regards

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Split row into multiple row based on column text

    There is a button on column AA. Just press it.
    Attached Files Attached Files

+ 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. How to split worksheet into multiple worksheets based on column content
    By jjexcels in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 11-05-2013, 11:42 AM
  2. [SOLVED] How to split worksheet into multiple worksheets based on column content
    By johnboytweed in forum Excel General
    Replies: 12
    Last Post: 10-16-2013, 12:01 PM
  3. Split Excel into Multiple csv files based upon the sum of column count.
    By sukanya123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2013, 07:28 PM
  4. Split data into multiple documents based on specific column
    By v_nastey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2013, 08:56 AM
  5. [SOLVED] Need macro to split one column into multiple columns based on _ and spacing
    By snely in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-17-2012, 10:05 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