Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have been using the following code to combine sheets from workbook
saved in a folder called "MyData" andit has been working fine. However today i am being told that "Method 'Copy' of object 'Sheets failed" and the lines wkbk.Worksheets.Copy After:=ThisWorkbook. _ Worksheets(ThisWorkbook.Worksheets.Count) are highlighted as the problem. I can't figure out whats going on an how to fix it. Can anyone help please (I have included the complet code below...) Sub GetSheets() Dim sPath As String, i As Long Dim varr As Variant Dim wkbk As Workbook sPath = "C:\MyData\" varr = Array("Data1.xls", "Data2.xls", "Data3.xls") For i = LBound(varr) To UBound(varr) Set wkbk = Workbooks.Open(sPath & varr(i)) wkbk.Worksheets.Copy After:=ThisWorkbook. _ Worksheets(ThisWorkbook.Worksheets.Count) wkbk.Close SaveChanges:=False Next End Su -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with tweaking formula | Excel Worksheet Functions | |||
macro tweaking | Excel Discussion (Misc queries) | |||
Tweaking formula? | Excel Discussion (Misc queries) | |||
Linking Wkbks | Excel Discussion (Misc queries) | |||
Searching range for value (code written but needs 'tweaking'!) | Excel Programming |