+ Reply to Thread
Results 1 to 8 of 8

Run-time error '1004' Sorry we couldnt find.... file path

  1. #1
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Run-time error '1004' Sorry we couldnt find.... file path

    I have set file location as

    Please Login or Register  to view this content.
    Following code works to reach to file1
    Please Login or Register  to view this content.
    But I want a cycle of code like following

    Please Login or Register  to view this content.
    Error (appearing on line Filename:=Nfile) says, we could not find file1.xlsx

    I have tried (Filename:="file" & f) Or (Filename:=file & f) but get same error.
    Last edited by caabdul; 03-01-2018 at 07:15 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    You could use an array like this.

    Please Login or Register  to view this content.
    But I would add .Value after the file1, file2 and file3 range assignments. eg. file1 = ThisWorkbook.Sheets("Main").Cells(8, 7).Value, Just to be on the safe side and prevent any compiler problems. You can only concatenate string values and in this case file1, while holding a string value is a code variable and not a real string.
    Last edited by JLGWhiz; 03-01-2018 at 07:12 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    Hi JLGWhiz, Great it works

    I have also added .vlaue

    I still can't understand why my code was not working, seems file names loops don't work without arrays?

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    Quote Originally Posted by caabdul View Post
    Hi JLGWhiz, Great it works

    I have also added .vlaue

    I still can't understand why my code was not working, seems file names loops don't work without arrays?
    You probably missed what I added on about trying to concatenate non-string values. When you declare a variable like 'file1', the whole six digits is the variable name and when you initialize that variable, it becomes code, not a string. So you can't take part of it and concatenate the other part to it because VBA does not know what the two parts are when separated, even though you are trying to put them back together, it just won't work. They are not recognized by VBA as valid strings in the code.

  5. #5
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    You could have written the loop like this
    Please Login or Register  to view this content.
    I forgot to adjust the range in the last line of the loop before. It would have been +1 in the other post.
    Last edited by JLGWhiz; 03-01-2018 at 07:37 PM.

  6. #6
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    Thanks for explaining. It makes sense

    I am having a small trouble in reaching "Rw" with ThisWorkbook.Sheets("Rw")

    I think the code goes to file1.xlsx to find "Rw" sheet instead of finding this sheet in my importing workbook which has name TotalRows.xlsx

    Is there a way that I set ThisWorkbook to TotalRows.xlsx? so code searches TotalRows.xlsx fiel when I write ThisWorkbook.Sheets("Rw")

    Thanks

  7. #7
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    Sorry I was wrong. It does not look into file1.xlsx to find "Rw" sheet

    instead there is some other issue. Error is Run time error 1004, Select method of range class failed.

  8. #8
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Run-time error '1004' Sorry we couldnt find.... file path

    Quote Originally Posted by caabdul View Post
    Sorry I was wrong. It does not look into file1.xlsx to find "Rw" sheet

    instead there is some other issue. Error is Run time error 1004, Select method of range class failed.
    I don't see 'Select' in any of the code you posted but maybe you are trying to select something that is not a selectable object. When you click the 'Debug' button it should show you the line of code where the error occrred and if you can't solve it yourself you can post the relevant code so we can see it too.

+ 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] VBA Code - Run-time Error 1004 can't find file
    By hhelgerson in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-26-2017, 07:42 PM
  2. HELP! Error 1004 - Temporary File Path not found
    By pipplesqueak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2016, 04:01 PM
  3. Replies: 3
    Last Post: 10-27-2015, 12:26 AM
  4. Run time error 75 (Path/File Access Error) - Excel 2007 on XP SP3
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2014, 10:39 AM
  5. [SOLVED] Run time error 75 (Path/File Access Error)
    By Riggers in forum Excel Programming / VBA / Macros
    Replies: 44
    Last Post: 03-05-2012, 04:51 PM
  6. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  7. Run-time error 75 Path/File access error
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2006, 02:20 PM

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