Checking Set of Files exist in the specific Path

  • Hi everyone,


    Seeking some help on below;


    i have created a Userform with Listbox, Textbox & Lable

    the Listbox shows the list of files are folder based on the path mentioned in Textbox.

    the Dir Path is well restricted and Textbox is not Visible so that user cannot go to desired path.


    Now in a Sheet (eg: Sheet7(i + 1, 1) ) i have list of Mandatory files a Folder should have to consider as Completed.

    if those files exist no matter what extension the Lable caption as Complete else Lable Caption as InComplete.



    Can some one Please Help me on this.


    Thanks alot.

  • Hi,


    To test if file exists, you can use following UDF


    Code
    1. Function FileExists(FileName As String) As Boolean
    2. FileExists = (Dir(FileName) > "")
    3. End Function


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Appreciate if you can explain how this works please....

  • When using the function FileExists()


    You need to use the full file name (including the path) inside the function to define the variable FileName


    As a result, you will get either True or False ...


    Hope this clarifies

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • is My Loop code correct.


    i need to check each file name against the sheet cells in a column.

  • Hi again,


    Should you have for example in range A2:A20 the list of your files to be checked ...



    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • As explained in message #4 you do need to use the full file name (including the path)


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Due to File Extension, is says file Does not Exist.

  • Hello,


    If the issue you are facing is related to the extension ... you can have :


    10-Covering Schedule.*


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • i achieved the using below code, but it doesn't scan the sub folders, anything you can think of to make it check sub folder also


  • Your requests are extremely confusing ...!!!


    If you are now looking for VBA code to loop through your files using the File System Object ( FSO ) for your main folder and sub folders ...


    you should take a look at following link ... and adapt code to your specific situation :


    https://exceloffthegrid.com/vb…files-folder-sub-folders/


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)