transpose rows to column (cell)

G

Gary Keramidas

you can give this code a try, it puts the results on a separate sheet. didn't
have a lot of time to test it.

Sub test()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim lastrow As Long
Dim lastcol As Long
Dim i As Long
Dim y As Long
Dim z As Long

y = 1
Set ws = Worksheets("sheet1")
Set ws2 = Worksheets("sheet2")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
ws2.Cells.Clear
With ws
For i = 1 To lastrow
For z = 4 To lastcol
ws2.Range("A" & y & ":C" & y).Value = ws.Range("A" & i &
":C" & i).Value
ws2.Cells(y, 4).Value = ws.Cells(i, z).Value
y = y + 1
Next
Next
End With
End Sub


--


Gary Keramidas
Excel 2003


in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top