+ Reply to Thread
Results 1 to 3 of 3

Error opening files from a list in a spreadsheet

  1. #1
    Anolan
    Guest

    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. #2
    Registered User
    Join Date
    02-11-2005
    Posts
    85
    Try putting

    On Error Resume Next

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

    Hope it helps.

  3. #3
    Anolan
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1