Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default copy worksheet from inactive workbook

I want to copy an entire worksheet from an inactive workbook without opening
it. Would someone be so kind as to talk me through this? For more
background, I am having the user enter a list of file names; I want to
automatically copy a certain worksheet (same name each workbook) from each of
the listed workbooks into the active workbook. I have code working that
copies the names of the listed workbooks into a string array (not sure if
that was the way to go or not).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default copy worksheet from inactive workbook

You're going to need to open the workbook in order to copy the worksheet.
You could open it as READ ONLY.

You could try something liket this:

Dim oWB As Workbook
Dim oWS As Worksheet
Dim aWB As Workbook
Set aWB = activebook

Dim Filename As String
Filename = aws.Cells(1, 1).Value '<~~~ change this It should be something
like C:\Documents and Settings\Customer\My Documents\filename.xls
Set oWB = Workbooks.Open(Filename, UpdateLinks:=False, ReadOnly:=True)
On Error Resume Next
Set oWS = oWB.Worksheet("Sheet1") '<~~~~CHANGE THE SHEET NAME HERE
On Error GoTo 0
If Not oWS Is Nothing Then
oWS.Copy AFTER:=aWB.Sheets(aWB.Worksheets.Count)
End If




"br549" wrote:

I want to copy an entire worksheet from an inactive workbook without opening
it. Would someone be so kind as to talk me through this? For more
background, I am having the user enter a list of file names; I want to
automatically copy a certain worksheet (same name each workbook) from each of
the listed workbooks into the active workbook. I have code working that
copies the names of the listed workbooks into a string array (not sure if
that was the way to go or not).

Reply
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
Adv. Filter - Want to copy to inactive sheet Maki Excel Discussion (Misc queries) 7 January 20th 10 12:59 PM
Adv. Filter - Want to copy to inactive sheet Maki Excel Discussion (Misc queries) 1 January 12th 10 10:50 PM
How do I email an inactive copy of a worksheet Jackaroo 1281 Excel Discussion (Misc queries) 1 January 1st 09 03:36 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 06:55 PM
How to get the activecell of inactive worksheet ? steven[_2_] Excel Programming 5 April 18th 04 12:59 PM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"