row to columns

Lavan

Board Regular
Joined
Dec 15, 2004
Messages
56
Hello,

I need a macro to convert row to columns. My data like below

Forest:A
Tree:A
Tree:B
Tree:C

Forest:B
Tree:A
Tree:B
Tree:C
Tree:D

Forest:z1

Forest:1
Tree:1
Tree:2
Tree:5
Tree:10
Tree:15

Forest:X
Tree:A
Tree:1
Tree:Z
Tree:33

Forest:20
Tree:A

I want this data in the spread to be converted into columns like below.

Forest Tree Tree Tree Tree Tree
A A B C
B A B C D
z1
1 1 2 5 10 15
X A 1 Z 33
20 A


Any help is greatly appriciated. Thanks in advance.

Lavan
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Dylan

Board Regular
Joined
Jul 27, 2007
Messages
150
Code below will transpose data in active sheet to Sheet2.
Code:
Sub Test()
colNum = 1
line1:

If Not IsEmpty(Cells(1, colNum)) Then
    lastRow = Cells(Rows.Count, colNum).End(xlUp).Row
    For I = 1 To lastRow
        Cells(I, colNum).Copy Destination:=Sheets("Sheet2").Cells(colNum, I)
    Next I
    colNum = colNum + 1
    GoTo line1
End If

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,668
Messages
5,597,463
Members
414,145
Latest member
lonnie451

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
Top