Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Copy method of Worksheet class failed?

I have a procedure that opens 60 files and copied 1 sheet from each
file into a single workbook to consolidate the data. The procedure
runs great until I get the the 35th file, and then I get an error:
Copy method of Worksheet class failed. The debugger highlights the
line of code below that I have in front of:

Sub OpenFiles()
Dim GetFiles As Variant
Dim iFiles As Long
Dim nFiles As Long
Dim wkbk As Workbook

GetFiles = Application.GetOpenFilename _
(FileFilter:="Text Files (*.*),*.*", _
Title:="Select Budget Templates to Include in SAP Upload",
MultiSelect:=True)
If TypeName(GetFiles) = "Boolean" Then
MsgBox "No Files Selected", vbOKOnly, "Nothing Selected"
End
Else
For iFiles = LBound(GetFiles) To UBound(GetFiles)
Workbooks.OpenText fileName:=GetFiles(iFiles)
Set wkbk = ActiveWorkbook

wkbk.Sheets("Opex & CAPEX").Copy

After:=ThisWorkbook.Worksheets(3)
With ActiveSheet.UsedRange
.Value = .Value
End With
wkbk.Close
Next iFiles
End If

End Sub

Any ideas on how to fix this?? Thanks in advance!!

-Steph
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Copy method of Worksheet class failed?

It might be the problem described he

http://support.microsoft.com/default...34&Product=xlw

--
Jim Rech
Excel MVP
"Steph" wrote in message
om...
I have a procedure that opens 60 files and copied 1 sheet from each
file into a single workbook to consolidate the data. The procedure
runs great until I get the the 35th file, and then I get an error:
Copy method of Worksheet class failed. The debugger highlights the
line of code below that I have in front of:

Sub OpenFiles()
Dim GetFiles As Variant
Dim iFiles As Long
Dim nFiles As Long
Dim wkbk As Workbook

GetFiles = Application.GetOpenFilename _
(FileFilter:="Text Files (*.*),*.*", _
Title:="Select Budget Templates to Include in SAP Upload",
MultiSelect:=True)
If TypeName(GetFiles) = "Boolean" Then
MsgBox "No Files Selected", vbOKOnly, "Nothing Selected"
End
Else
For iFiles = LBound(GetFiles) To UBound(GetFiles)
Workbooks.OpenText fileName:=GetFiles(iFiles)
Set wkbk = ActiveWorkbook

wkbk.Sheets("Opex & CAPEX").Copy

After:=ThisWorkbook.Worksheets(3)
With ActiveSheet.UsedRange
.Value = .Value
End With
wkbk.Close
Next iFiles
End If

End Sub

Any ideas on how to fix this?? Thanks in advance!!

-Steph



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
Why am I getting R/T 1004 - Copy method of Rng class failed? Jim May Excel Discussion (Misc queries) 2 April 21st 08 05:14 PM
Error 1004 Copy method of worksheet class failed Ayo Excel Discussion (Misc queries) 3 March 28th 08 02:05 PM
Paste method of worksheet class failed error Todd Huttenstine[_2_] Excel Programming 1 December 16th 03 10:08 AM
Open Method of workbooks class failed kiran[_2_] Excel Programming 0 November 6th 03 09:58 PM
Copy Method of Workseet Class Failed Tom Kosensky Excel Programming 1 July 15th 03 09:54 AM


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