+ Reply to Thread
Results 1 to 2 of 2

"Run-time error '1004': '111_02_03_2019.csv' could not be found

  1. #1
    Registered User
    Join Date
    07-14-2020
    Location
    Houston
    MS-Off Ver
    2018
    Posts
    1

    "Run-time error '1004': '111_02_03_2019.csv' could not be found

    Hello everyone,

    I'm pretty new to Excel so I've been following code from someone else online and plan to tailor it to my needs. I'm currently having this error.

    The error is: "Run-time error '1004': '111_02_03_2019.csv' could not be found. Check the spelling of the file name, and verify that the file location is correct. If you are trying to open a file from your list of most recently used files, make sure that the file has not been renamed, moved or deleted."

    Any ideas on what's wrong? I haven't been able to find anything else on it online.

    Option Explicit

    Dim wsMerge As Worksheet
    Dim RowInsert As Long
    ' which row can I insert my dataset?


    Sub Merge_PolarFiles()
    Const FolderPath As String = "C:\Users\anip\Desktop\File Retrieve Polar 007 - Copy\"
    ' need to choose location

    Dim Files As String
    Dim wbTemp As Workbook
    Dim LastRow As Long

    Set wsMerge = ThisWorkbook.Worksheets("Merge")

    Call ClearMergeWorksheet

    RowInsert = 2

    Files = Dir(FolderPath + "*.csv")

    Do Until Files = ""

    Set wbTemp = Workbooks.Open(Files)

    With wbTemp.Worksheets(1)

    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row

    .Range("M2:LastRow,AU2:LastRow").Copy
    wsMerge.Range("A" & RowInsert).PasteSpecial xlPasteValues

    Application.DisplayAlerts = False
    wbTemp.Close False
    Application.DisplayAlerts = True

    RowInsert = RowInsert + LastRow - 1

    End With

    Files = Dir()

    Loop


    MsgBox "File Merge Complete", vbInformation

    End Sub




    Private Sub ClearMergeWorksheet()
    Dim LastRow As Long

    With wsMerge
    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row

    If 2 > LastRow Then Exit Sub

    '.Range("A2:N" & LastRow).ClearContents
    .Range("A2:CE" & LastRow).ClearContents

    End With

    End Sub

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: "Run-time error '1004': '111_02_03_2019.csv' could not be found

    1)
    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    2) Ampersand, "&", should be used for string concatenation in vba.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] run time error 1004 no cells were found
    By iwannabakat in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2014, 04:13 PM
  2. [SOLVED] Workbooks.Open method and runtime error 1004 - "file couldn't be found".
    By PHBlaz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-28-2014, 02:10 PM
  3. Vlook up VBA Error when value not found "runtime error -1004"
    By sriram170 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2013, 01:14 PM
  4. [SOLVED] Macro button generates "run time error 1004 [FileName] could not be found' msg
    By dawnmau in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-12-2012, 11:55 AM
  5. Run-time error '1004': No cells were found
    By tirk82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2012, 12:48 PM
  6. Run Time Error 1004: File not found
    By rajasekhar28 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2010, 02:34 PM
  7. Run time error 1004: "No list was found.."
    By hachiroku in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2006, 07:55 AM

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