H
Howard
In workbook, I have six sheets. Sheets 1, 2 & 3 have data in column A with varied number of rows.
The code here copies each of those columns to sheet 4, Column A. BUT does it twice. Sheet data 1, 2, 3 listed in sheet 4 followed by an identical list right below the first.
Once I get the double copy solved, I intend to use an array with the elements as the sheets I want to copy from. There is a sheet 5 & 6 but they are blank now. Still I would prefer to avoid even looking at them unless they were included in the array.
Thanks,
Howard
Option Explicit
Sub ThreeColumnsToOne()
Dim lastRow As Long, lastRowDest As Long
Dim ws As Worksheet
Application.ScreenUpdating = False
lastRowDest = 1
For Each ws In ThisWorkbook.Sheets
lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A1:A" & lastRow).Copy Destination:=Sheets("Sheet4").Range("A" & lastRowDest)(1)
lastRowDest = Sheets("Sheet4").Range("A" & Rows.Count).End(xlUp).Row + 1
Next
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub
The code here copies each of those columns to sheet 4, Column A. BUT does it twice. Sheet data 1, 2, 3 listed in sheet 4 followed by an identical list right below the first.
Once I get the double copy solved, I intend to use an array with the elements as the sheets I want to copy from. There is a sheet 5 & 6 but they are blank now. Still I would prefer to avoid even looking at them unless they were included in the array.
Thanks,
Howard
Option Explicit
Sub ThreeColumnsToOne()
Dim lastRow As Long, lastRowDest As Long
Dim ws As Worksheet
Application.ScreenUpdating = False
lastRowDest = 1
For Each ws In ThisWorkbook.Sheets
lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A1:A" & lastRow).Copy Destination:=Sheets("Sheet4").Range("A" & lastRowDest)(1)
lastRowDest = Sheets("Sheet4").Range("A" & Rows.Count).End(xlUp).Row + 1
Next
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub