VBA

  • Thread starter Thread starter missk
  • Start date Start date
M

missk

Pls help me with this macro:

I have data which has the following format

Row1 A B C D E F G H
I J K L M N
Row2 9434 20060111 231 56 1.1 TEP 37 1.2 TEQ
0 0 TER 0 0

The data goes to column BJ.

I wish to to sort this data as follows

A B C D E
9439 20060111 231 56 1.1
9439 20060111 TEP 37 1.2
9439 20060111 TEQ 0 0
9439 20060111 TER 0 0

Thanks
 
Hi,

Try this which writes tranposed data on Sheet1 to Sheet2


Sub TransposeData()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, outrow As Long, c As Integer

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("sheet2")

outrow = 2
ws1.Activate
With ws1
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
For r = 2 To lastrow
For c = 3 To 62 Step 3
.Cells(r, 1).Resize(1, 2).Copy ws2.Cells(outrow, 1)
.Cells(r, c).Resize(1, 3).Copy ws2.Cells(outrow, 3)
outrow = outrow + 1
Next c
Next r

End With

End Sub


HTH
 

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

Back
Top