Copy between workbooks from a third workbook.

Solved/Closed
Orebody Posts 1 Registration date Monday January 17, 2011 Status Member Last seen January 17, 2011 - Jan 17, 2011 at 09:14 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jan 19, 2011 at 08:53 AM
Hello,
I would like to make an excel macro that will sit in a stand alone workbook (Workbook1).
This macro would select a single user-defined worksheet from Workbook2 and paste it in to Workbook 3.
I can get it to copy the worksheet from Workbook 2 but getting it to paste into Workbook 3 is a bit beyond me. Any help will be greatly appreciated.

Here is my current code which copies from Workbook2 and pastes into Workbook1.
I played around with trying to get it to paste to Workbook3 but it all fell in a heap :)
I'm using Excel 2007.

Sub GetFile()
Sheets("menu").Select
PathName = Range("D3").Value
Filename = Range("D4").Value
Worksheet = Range("D5").Value
TabName = Range("D6").Value
ControlFile = ActiveWorkbook.Name
Workbooks.Open Filename:=PathName & Filename
Worksheets(Worksheet).Activate
ActiveSheet.Name = TabName
Sheets(TabName).Copy After:=Workbooks(ControlFile).Sheets(1)
Windows(Filename).Activate
ActiveWorkbook.Close SaveChanges:=False
Windows(ControlFile).Activate
Sheets("menu").Select
Range("D9").Select
ActiveCell.Value = "Completed"
Range("D10").Select
End Sub


1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jan 19, 2011 at 08:53 AM
Well for one, it may not be a good idea to copy the sheet. Depending how much data is on a cell, copying sheets can result in truncated values. Could you paste your attempted code of copying the data to third workbook.
0