VBA / Copy,Transpose and Paste into different sheet

leeb91

New Member
Joined
May 22, 2015
Messages
20
Hi,
I am trying to copy a range of data
(from row2 ~ to the last row in column C in Sheet1)
and transpose, and paste the values to A1 ~ to the end of the row.
The number of rows and columns vary for each data file and got to this point


Worksheets(1).Range("C2:").Copy
Worksheets(2).Range("A1").PasteSpecial Transpose:=True


where the problem is that I need to select the whole column C
in sheet1 from row 2. Is this possible at all?

Please help me I am stuck.
Thanks in advance.
 

Excel Facts

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

Code:
    [color=darkblue]With[/color] Worksheets(1)
        .Range("C2", .Range("C" & Rows.Count).End(xlUp)).Copy
    End [color=darkblue]With[/color]
    Worksheets(2).Range("A1").PasteSpecial Transpose:=[color=darkblue]True[/color]
 
Upvote 0
leeb91,

Here is a macro solution for you to consider.

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub leeb91()
' hiker95, 06/01/2015, ME858540
Sheets(1).Range("C2", Cells(Rows.Count, "C").End(xlUp)).Copy
Sheets(2).Range("A1").PasteSpecial Transpose:=True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the leeb91 macro.
 
Last edited:
Upvote 0
Code:
Sub leeb91()
' hiker95, 06/01/2015, ME858540
Sheets(1).Range("C2", Cells(Rows.Count, "C").End(xlUp)).Copy
Sheets(2).Range("A1").PasteSpecial Transpose:=True
End Sub

Heads up: This could throw an error if Sheets(1) is not the active sheet as Cells(Rows.Count, "C").End(xlUp) is unqualified and will default to the active sheet creating a Range reference on two different sheets.
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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