Transposing Data

jonas10

New Member
Joined
Jan 31, 2011
Messages
30
Hi, I am hoping someone can help me out transposing some data. Ive got a raw excel file with all the data in column A. Every 21 lines this is suppose to be posted across the same row. I've tried manually selecting every 21 lines and repasting this with the transpose option. Problem is that there are hundreds of sample sizes that i need to do this with on a monthly basis.

Is there a quick way to have every 21 lines automatically in the same row?

Thank you!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about
Code:
Sub TransPaste()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, i As Long, j As Long
   Ary = Range("A1", Range("A" & Rows.Count).End(xlUp))
   ReDim Nary(1 To UBound(Ary) / 21, 1 To 21)
   For i = 1 To UBound(Ary) Step 21
      r = r + 1
      For j = i To i + 20
         c = c + 1
         Nary(r, c) = Ary(j, 1)
      Next j
      c = 0
   Next i
   Range("A:A").ClearContents
   Range("A1").Resize(UBound(Nary), UBound(Nary, 2)).Value = Nary
End Sub
 
Upvote 0
Here is another macro that you can consider...
Code:
[table="width: 500"]
[tr]
	[td]Sub TransPaste()
   Dim R As Long
   Application.ScreenUpdating = False
   For R = 1 To Cells(Rows.Count, "A").End(xlUp).Row Step 21
     Cells((R + 20) / 21, "A").Resize(, 21) = Application.Transpose(Cells(R, "A").Resize(21))
   Next
   Range(Cells(Rows.Count, "B").End(xlUp).Offset(1, -1), Cells(Rows.Count, "A").End(xlUp)).ClearContents
   Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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