LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Copy pasting a range in to a single column

Hi,

I have data in column O (starting from row number 2) and it could extend up
to let's say till column T within a worksheet called "basesheet". the number
of rows will be variable.

There is a pattern for data being filled up in these columns. Column O is
never empty. But, ...if column P is empty then all columns after that will
be empty for that row. Similarly if column Q is empty then all columns after
that will be empty and so on...

I want to copy all the Non-empty cells from column O to column T in to
another New Workbook, starting from Cell A1 within a SINGLE COLUMN. (using
Transpose)

Whats the most efficient way (time- wise). I have pasted my attempt below.

Please tell the places where I can make the code faster. ( Basically, I have
to do this for around 70 worksheets and many rows, thats why Iam asking for
a more efficient code).



Option Explicit

Sub try()

Dim NewWorkBookName As String
Dim i As Long

Workbooks.Add
NewWorkBookName = ActiveWorkbook.Name

ThisWorkbook.Worksheets("basesheet").Activate

For i = 2 To Range("o65536").End(xlUp).Row

Cells(i, Range("iv" & i).End(xlToLeft).Column).Select
Debug.Assert (ActiveCell.Row < 9)
If ActiveCell.Column = 15 Then
ActiveCell.Copy
Else
Range(ActiveCell, Cells(i, "o")).Copy
End If

Workbooks(NewWorkBookName).sheets("sheet1").Activa te
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:=False, Transpose:=True
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select

ThisWorkbook.Worksheets("basesheet").Activate
Next i

End Sub


Thanks a lot,
Hari
India


 
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 do I prevent copy and pasting into a selected range of a works oasalako1 Excel Discussion (Misc queries) 1 November 20th 07 01:29 PM
Copy Range From Multiple Worksheets to a Single Worksheet Dauntless1 Excel Discussion (Misc queries) 5 August 17th 07 01:59 AM
Copy column range of "single word" cells with spaces to a single c nastech Excel Discussion (Misc queries) 3 February 15th 06 05:04 PM
copy and pasting a find all list into another column Ben Excel Discussion (Misc queries) 18 December 31st 05 10:51 PM
How to I copy text from a range of cells to another single cell? WRT Excel Discussion (Misc queries) 2 December 18th 05 06:17 AM


All times are GMT +1. The time now is 10:01 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"