Copy & Paste Transpose in Another Sheet

dgr

Board Regular
Joined
Apr 24, 2005
Messages
176
Hi,
I'm using Excel 2013.

I would like to copy every 150 rows of data from column A of Sheet 1 & paste special in a transpose manner into Sheet 2. I would like this process to go on until there is no more data in Sheet 1 to copy. The end result should be all data is pasted in Sheet 2 in a transpose manner & there should no longer be any data in Sheet 1.

I've gone as far as creating this macro which works fine but doesn't seem to loop. Could you please help me to edit this code so that it loops until there is no more data in Sheet 1 to copy?

Thanks.
Code:
Sub test()

ActiveSheet.Name = "Sheet1"
    Dim wsData As Worksheet
    Dim wsNew As Worksheet
    Dim rng As Range
    Dim I As Long
     
    Set wsData = Worksheets("Sheet1")
    Set wsNew = Worksheets("Sheet2")
     
    Set rng = wsData.Range("A1")
    While rng.Value <> ""
        I = I + 1
        rng.Resize(150).Copy
        wsNew.Range("A" & I).PasteSpecial xlPasteValues, Transpose:=True
        Set rng = rng.Offset(150)
    Wend
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try

Code:
Sub test()

    Dim wsData As Worksheet
    Dim wsNew As Worksheet
    Dim rng As Range
     
    Set wsData = Worksheets("Sheet1")
    Set wsNew = Worksheets("Sheet2")
     
    Set rng = wsData.Range("A1")
    While rng.Value <> ""
        rng.Resize(150).Copy
        wsNew.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues, Transpose:=True
        Set rng = rng.Offset(150)
    Wend
End Sub
 
Upvote 0
Thanks a lot VoG. This is exactly what I was looking for. I appreciate your help. Have a blessed day :)
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,443
Members
448,898
Latest member
drewmorgan128

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