Traspose columns into rows, copying data from the original row in the new ones

alvaro_v_b

New Member
Joined
Mar 29, 2016
Messages
2
Hello Everybody!

I have a difficult task ahead and I am not sure if what I want to do is possible to be done in an authomatic way.
I have a data base with several fields/columns: A, B, C, D. In the last one (D), each field contains several words separated by a delimiter.
What I want is, for each row to generate as many rows as delimited words in column D, filling columns A, B and C with the same content of the original row.
For instance, I want to automaticly transform something like this:
ShapeKey

<tbody>
</tbody>
Class

<tbody>
</tbody>
Subclass

<tbody>
</tbody>
Products

<tbody>
</tbody>
1104

<tbody>
</tbody>
12
13
Parade floats;Motor cars;Mobile laboratories;Motor graders ;Trucks for liquid manure

<tbody>
</tbody>
65
12
02
Trolleys;Wheel carriers ;Dollies

<tbody>
</tbody>

<tbody>
</tbody>

Into something like this:

ShapeKey
Class
Subclass
Products
1104
12
13
Parade floats
1104
12
13
Motor cars
1104
12
13
Mobile laboratories
1104
12
13
Motor graders
1104
12
13
Trucks for liquid manure
65
12
02
Trolleys
65
12
02
Wheel carriers
65
12
02
Dollies

<tbody>
</tbody>

(In the real case I have many more rows)
Does anybody know if this is possible in Excel?

THANK YOU SO MUCH IN ADVANCE FOR YOUR HELP!!

Alvaro
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Re: Traspose columns intro rows, copying data from the original row in the new ones

This macro will place you new data in Shet2. Change the sheet names in the macro to suit your needs.
Code:
Sub SplitCells()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim Product As Range
    Dim prodArray As Variant
    Dim i As Long
    Sheets("Sheet1").Rows(1).Copy Sheets("Sheet2").Cells(1, 1)
    For Each Product In Sheets("Sheet1").Range("D2:D" & LastRow)
        prodArray = Split(Product, ";")
        For i = LBound(prodArray) To UBound(prodArray)
            Sheets("Sheet1").Range("A" & Product.Row & ":C" & Product.Row).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
            Sheets("Sheet2").Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = prodArray(i)
        Next i
    Next Product
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Re: Traspose columns intro rows, copying data from the original row in the new ones

Wow mumps, this looks great!!
I have just tried it and it works perfectly, CONGRATULATIONS AND THANK YOU SO MUCH!
 
Upvote 0
Re: Traspose columns intro rows, copying data from the original row in the new ones

You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,216,175
Messages
6,129,310
Members
449,499
Latest member
HockeyBoi

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