#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VBA

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VBA

Thank you so much

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"