View Single Post
  #5   Report Post  
Dougie13 Dougie13 is offline
Junior Member
 
Posts: 4
Default

Quote:
Originally Posted by Gord Dibben[_2_] View Post
A macro could be much faster when doing that many sheets.

Sub OneColumnV2()
''''''''''''''''''''''''''''''''''''''''''
'Macro to copy columns of variable length'
'into 1 continous column in a new sheet '
'Modified 17 FEb 2006 by Bernie Dietrick
''''''''''''''''''''''''''''''''''''''''''
Dim iLastcol As Long
Dim iLastRow As Long
Dim jLastrow As Long
Dim ColNdx As Long
Dim ws As Worksheet
Dim myRng As Range
Dim ExcludeBlanks As Boolean
Dim myCell As Range

ExcludeBlanks = (MsgBox("Exclude Blanks", vbYesNo) = vbYes)
Set ws = ActiveSheet
iLastcol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
On Error Resume Next

Application.DisplayAlerts = False
Worksheets("Alldata").Delete
Application.DisplayAlerts = True

Sheets.Add.Name = "Alldata"

For ColNdx = 1 To iLastcol

iLastRow = ws.Cells(ws.Rows.Count, ColNdx).End(xlUp).Row

Set myRng = ws.Range(ws.Cells(1, ColNdx), _
ws.Cells(iLastRow, ColNdx))

If ExcludeBlanks Then
For Each myCell In myRng
If myCell.Value < "" Then
jLastrow = Sheets("Alldata").Cells(Rows.Count, 1) _
.End(xlUp).Row
myCell.Copy
Sheets("Alldata").Cells(jLastrow + 1, 1) _
.PasteSpecial xlPasteValues
End If
Next myCell
Else
myRng.Copy
jLastrow = Sheets("Alldata").Cells(Rows.Count, 1) _
.End(xlUp).Row
myCell.Copy
Sheets("Alldata").Cells(jLastrow + 1, 1) _
.PasteSpecial xlPasteValues
End If
Next

Sheets("Alldata").Rows("1:1").entirerow.Delete

ws.Activate
End Sub


Gord

On Mon, 25 Jun 2012 21:35:40 +0000, Dougie13
wrote:


Spencer101;1603115 Wrote:
Hi,

4000 rows of data would probably be quicker to manipulate in this way
manually than it would be to write some kind of formula/VBA.

How often do you need to do this?


Hi, well I forgot to mention I have about 20 worksheets of the same type
which all need collating into one column in each worksheet. To add, I
get this about twice a month so a formula would be of great help, doing
in manually is undesirable really.

Thanks
Thanks Gord for your work here, it's much appreciated but I'm afraid I've no idea what to do with this? Do I have to type it out somewhere. Apologies but I'm very inexperienced in excel.