Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error opening files from a list in a spreadsheet

Help! I get Run-time error 1004 when I run the following macro. I have a
list of file names (ex: 1025104902.xls) in my personal.xls that is defined
by a range, say "GA". Sometimes an Excel file does not exist for a file name
in this list. In this case, I want the macro to bypass the file not found
error and resume the routine with the next file name in the list. Can anyone
please help me with the code that will do this? Thank you. Andy

Here is part of my code from it starts to where it stops:

Private Sub CommandButton1_Click()
' Report CC EV 100
' Format_100_Rpt Macro
' Macro recorded 11/8/2005 by anolasco
'
'
Dim myCell
Dim myRange
Dim myDir As String
Dim myDate As String
Dim myHeader As String
myRange = Application.InputBox(prompt:="Enter a Range", Type:=8)
myDir = Application.InputBox(prompt:="Enter File Location",
Default:="U:\CC_EV_100 Reports\mmyy\", Type:=2)
myDate = Application.InputBox(prompt:="Enter Date and Time",
Default:="mm/dd/yy hh:mm am", Type:=2)
myHeader = Application.InputBox(prompt:="Enter As of Date",
Default:="October 31, 2005", Type:=2)
Windows("PERSONAL.XLS").Visible = True
Workbooks("PERSONAL.XLS").Activate
Sheets("Sheet1").Select
For Each myCell In myRange
Workbooks.Open Filename:=myDir & myCell (run-time error 1004)
(In between I have code that does formatting and calcuations.)
Next myCell


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error opening files from a list in a spreadsheet


Try putting

On Error Resume Next

just before your loop. This will bypass the error code and continue
processing your code.

Hope it helps.


--
goober
------------------------------------------------------------------------
goober's Profile: http://www.excelforum.com/member.php...o&userid=19838
View this thread: http://www.excelforum.com/showthread...hreadid=487744

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error opening files from a list in a spreadsheet

Thank you. I will try it.

"goober" wrote:


Try putting

On Error Resume Next

just before your loop. This will bypass the error code and continue
processing your code.

Hope it helps.


--
goober
------------------------------------------------------------------------
goober's Profile: http://www.excelforum.com/member.php...o&userid=19838
View this thread: http://www.excelforum.com/showthread...hreadid=487744


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
opening files error Ria Excel Discussion (Misc queries) 1 April 7th 10 08:20 PM
Opening/converting other spreadsheet programs' files Conan Kelly Excel Worksheet Functions 2 January 12th 07 05:54 PM
Virus error opening all files whipwil Excel Worksheet Functions 2 October 5th 06 06:16 PM
data error while opening files [email protected] Excel Discussion (Misc queries) 2 February 3rd 06 07:29 AM
error opening .csv files Eric Johnson Excel Discussion (Misc queries) 2 December 16th 05 05:36 PM


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