Thread: VBA
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default VBA

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

"missk" wrote:

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