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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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