Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default paste transpose

I have a workbook with multiple pages. Each page has data in only first column.
I like to copy the data from the first column and paste transpose into first
2 rows.
and then delete the first column.
I have the following code, but it is not working properly.
1) it is not looping through the excel pages.
2. It is deleting the entire data ( not just the first column) except the
first cell.


Can you tell me where the code is wrong and also can you suggest a more
efficient way to do this.
thanks in advance.
###
Public Sub Paste_Transpose()
Dim ws As Worksheet

Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
Lastrow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row


Range(Cells(1, 1), Cells(Lastrow, 1)).Copy
Range(Cells(1, 1), Cells(2, Lastrow + 1)).PasteSpecial Paste:=xlPasteAll,
Transpose:=True
Range(Cells(1, 1), Cells(Lastrow, 1)).Delete
Next ws



End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default paste transpose

Sheela
Your code works on only the active sheet. The For loop loops through
all the sheets in the workbook, but your code says to work on only the
active sheet. So it does. I modified your code so that all the operations
are done to the ws sheet. HTH Otto
Public Sub Paste_Transpose()
Dim ws As Worksheet
Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
With ws
Lastrow = .Range("A" & Rows.Count).End(xlUp).Row
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).Copy
.Range(.Cells(1, 1), .Cells(2, Lastrow + 1)).PasteSpecial
Paste:=xlPasteAll, Transpose:=True
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).ClearContents
End With
Next ws
End Sub

"Sheela" wrote in message
...
I have a workbook with multiple pages. Each page has data in only first
column.
I like to copy the data from the first column and paste transpose into
first
2 rows.
and then delete the first column.
I have the following code, but it is not working properly.
1) it is not looping through the excel pages.
2. It is deleting the entire data ( not just the first column) except the
first cell.


Can you tell me where the code is wrong and also can you suggest a more
efficient way to do this.
thanks in advance.
###
Public Sub Paste_Transpose()
Dim ws As Worksheet

Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
Lastrow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row


Range(Cells(1, 1), Cells(Lastrow, 1)).Copy
Range(Cells(1, 1), Cells(2, Lastrow + 1)).PasteSpecial Paste:=xlPasteAll,
Transpose:=True
Range(Cells(1, 1), Cells(Lastrow, 1)).Delete
Next ws



End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default paste transpose


Thank you very much for the clarification.
I appreciate it.

sheela
"Otto Moehrbach" wrote:

Sheela
Your code works on only the active sheet. The For loop loops through
all the sheets in the workbook, but your code says to work on only the
active sheet. So it does. I modified your code so that all the operations
are done to the ws sheet. HTH Otto
Public Sub Paste_Transpose()
Dim ws As Worksheet
Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
With ws
Lastrow = .Range("A" & Rows.Count).End(xlUp).Row
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).Copy
.Range(.Cells(1, 1), .Cells(2, Lastrow + 1)).PasteSpecial
Paste:=xlPasteAll, Transpose:=True
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).ClearContents
End With
Next ws
End Sub

"Sheela" wrote in message
...
I have a workbook with multiple pages. Each page has data in only first
column.
I like to copy the data from the first column and paste transpose into
first
2 rows.
and then delete the first column.
I have the following code, but it is not working properly.
1) it is not looping through the excel pages.
2. It is deleting the entire data ( not just the first column) except the
first cell.


Can you tell me where the code is wrong and also can you suggest a more
efficient way to do this.
thanks in advance.
###
Public Sub Paste_Transpose()
Dim ws As Worksheet

Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
Lastrow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row


Range(Cells(1, 1), Cells(Lastrow, 1)).Copy
Range(Cells(1, 1), Cells(2, Lastrow + 1)).PasteSpecial Paste:=xlPasteAll,
Transpose:=True
Range(Cells(1, 1), Cells(Lastrow, 1)).Delete
Next ws



End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default paste transpose

Glad to help. Thanks for the feedback. Otto
"Sheela" wrote in message
...

Thank you very much for the clarification.
I appreciate it.

sheela
"Otto Moehrbach" wrote:

Sheela
Your code works on only the active sheet. The For loop loops through
all the sheets in the workbook, but your code says to work on only the
active sheet. So it does. I modified your code so that all the
operations
are done to the ws sheet. HTH Otto
Public Sub Paste_Transpose()
Dim ws As Worksheet
Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
With ws
Lastrow = .Range("A" & Rows.Count).End(xlUp).Row
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).Copy
.Range(.Cells(1, 1), .Cells(2, Lastrow + 1)).PasteSpecial
Paste:=xlPasteAll, Transpose:=True
.Range(.Cells(1, 1), .Cells(Lastrow, 1)).ClearContents
End With
Next ws
End Sub

"Sheela" wrote in message
...
I have a workbook with multiple pages. Each page has data in only first
column.
I like to copy the data from the first column and paste transpose into
first
2 rows.
and then delete the first column.
I have the following code, but it is not working properly.
1) it is not looping through the excel pages.
2. It is deleting the entire data ( not just the first column) except
the
first cell.


Can you tell me where the code is wrong and also can you suggest a more
efficient way to do this.
thanks in advance.
###
Public Sub Paste_Transpose()
Dim ws As Worksheet

Dim Lastrow As Long
For Each ws In ActiveWorkbook.Worksheets
Lastrow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row


Range(Cells(1, 1), Cells(Lastrow, 1)).Copy
Range(Cells(1, 1), Cells(2, Lastrow + 1)).PasteSpecial
Paste:=xlPasteAll,
Transpose:=True
Range(Cells(1, 1), Cells(Lastrow, 1)).Delete
Next ws



End Sub






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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how paste transpose reverse? Ian Elliott Excel Discussion (Misc queries) 2 September 19th 08 01:24 AM
Transpose, Paste Special idgity Excel Discussion (Misc queries) 2 September 6th 07 06:04 PM
Copy and transpose paste JohnP Excel Programming 0 June 5th 07 10:08 PM
How can I transpose a paste link? rpcar Excel Discussion (Misc queries) 2 September 1st 05 01:45 AM
Paste Special Transpose Brian Excel Programming 1 August 29th 05 03:43 PM


All times are GMT +1. The time now is 11:42 PM.

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

About Us

"It's about Microsoft Excel"