Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adv. Filter - Want to copy to inactive sheet | Excel Discussion (Misc queries) | |||
Adv. Filter - Want to copy to inactive sheet | Excel Discussion (Misc queries) | |||
How do I email an inactive copy of a worksheet | Excel Discussion (Misc queries) | |||
Copy Data from Workbook into specific Worksheet in other Workbook? | Excel Discussion (Misc queries) | |||
How to get the activecell of inactive worksheet ? | Excel Programming |