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: 536
Default Code copies twice...?

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
 
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
Code copies between key word is in reverse order Howard Excel Programming 5 August 27th 13 10:26 AM
Code For Copy Copies Twice PHisaw Excel Programming 2 October 22nd 09 03:47 AM
Number of copies to print keep defaulting to 12 copies why? Boski Excel Worksheet Functions 1 October 8th 09 05:33 PM
Code that searches a column, then copies and pastes any matches intoa new Spreadsheet Mike C[_5_] Excel Programming 5 February 8th 08 04:02 AM
Trying to eliminate multiple copies of the SAME code within a UserForm JimP Excel Programming 6 December 8th 04 12:45 AM


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