Column to Rows (not transpose)

TomOold

New Member
Joined
Mar 5, 2018
Messages
1
Hi all,

I have a document (export from DB) with order numbers and in the column to the right all the shipping codes for this order.
I need to have the shipping codes (with ordernumber) on seperate rows (see table below).

The shipping codes from column b to different columns is something I can do, but I do not know how to (automattically) put it to different rows with the order number in front of it.

Could you please help me?


Ordernr.Shipping Codes
2017001Shipping 1, Shipping 2, Shipping 3
2017002Shipping 4, Shipping 5
2017003Shipping 7, Shipping 8, Shipping 9, Shipping 10, Shipping 11

<tbody>
</tbody>
etc

to
OrdernrShipping Code
2017001Shipping 1
2017001Shipping 2
2017001Shipping 3
2017002Shipping 4
2017002Shipping 5
2017003Shipping 7
2017003Shipping 8
2017003Shipping 9
2017003Shipping 10

<tbody>
</tbody>
Etc.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi & welcome to the board.
How about
Code:
Sub SplitTranspose()

   Dim Cl As Range
   Dim Rws As Long
   
   Range("D1:E1").Value = Range("A1:B1").Value
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
      Rws = UBound(Split(Cl.Offset(, 1), ",")) + 1
      With Range("D" & Rows.Count).End(xlUp).Offset(1)
         .Resize(Rws).Value = Cl.Value
         .Offset(, 1).Resize(Rws).Value = Application.Transpose(Split(Cl.Offset(, 1), ","))
      End With
   Next Cl

End Sub
 
Upvote 0
If the output is comma separated, one of possible (semi)automated solutions could be:
1. change it into separate cells with text-to-columns tool,
2. Unpivot data (see for examle how to use Multiple Consolidation Ranges PivotTable for it here: https://superuser.com/questions/78439/how-to-unpivot-or-reverse-pivot-in-excel
3. Remove empty column B entries (with autofilter)
 
Upvote 0

Forum statistics

Threads
1,215,777
Messages
6,126,835
Members
449,343
Latest member
DEWS2031

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