Split cells in a list to create a longer list

richardallen

New Member
Joined
Feb 13, 2014
Messages
12
Grateful with some help on a vba task. I am looking to use convert this list:

ABC21256/03/04
ABC21311/01/09/11
ABC21313/02
ABC21378/07/08/31

into to this list:

ABC21256/03
ABC21256/04
ABC21311/01
ABC21311/09
ABC21311/11
ABC21313/02
ABC21378/07
ABC21378/08
ABC21378/31

i.e. each line is split after the "/" and concatenated with the starting string (before the first "/") to create a new sequence and put on separate rows.
 
What would I change to have the data lists start from row 2 (so I can add titles for the user)?
For the code I posted in Message #6 , you would change the A1 to A2 on the code line assigning to the Addr variable and change the B1 to B2 on the last code line.
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Brilliant, thanks. Finally, what would the code be to reverse this? i.e. reassemble a dis-aggregated list:

From:
ABC21256/03

ABC21256/04
ABC21311/01
ABC21311/09
ABC21311/11

To:
ABC21256/03/04
ABC21311/01/09/11
Here is my non-looping method to do this (it is the complement to the non-looping code I posted to your original question in Message #6 ). Note that I assumed your data started at cell A2 with A1 containing header text... if that is the wrong starting cell, simply change the A2 to what the actual starting cell is for you data.
Code:
[table="width: 500"]
[tr]
	[td]Sub ReassembleWithSlashes()
  With Range("A2", Cells(Rows.Count, "A").End(xlUp))
    .Copy .Offset(, 1)
    .Offset(, 1) = Evaluate(Replace(Replace("IF(LEFT(@,FIND(""/"",@)-1)=LEFT(#,FIND(""/"",#&""/"")-1),REPLACE(@,1,FIND(""/"",@)-1,""""),@)", "@", .Offset(, 1).Address), "#", .Offset(-1, 1).Address))
    With .Offset(, 1)
      .Value = Application.Transpose(Split(Replace(Join(Application.Transpose(.Cells), Chr(1)), Chr(1) & "/", "/"), Chr(1)))
      .SpecialCells(xlConstants, xlErrors).Clear
    End With
  End With
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,568
Messages
6,125,599
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top