Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to look into the FileSystemObject, as this lets you look at stuff to do with the FileSystem.</p> <p>I've made a quick example, although it might not do anything like what your trying to do as I wasn't completely sure. I hope it's fairly easy to understand.</p> <p>The following code, if placed inside a module, will give you access to the "checkList" function in your worksheet.</p> <p>The checkList function will loop through a cached list of file names from your specified folder, checking to see if the parameter "Name" matches any of the items stored in the list.</p> <p>The cached list of files (the FileList collection) get populated once, the first time checkList is called by the loadList sub.</p> <p>The loadList sub reads through your specified folder and adds all the file names to the collection.</p> <pre><code>' Global Variable, used to cache the filenames Public FileList As Collection ' this function returns "" if no match was found, and returns the file name if found. Public Function checkList(ByVal Name As String) As String Dim Result As String Dim Item As Variant Result = "" If FileList Is Nothing Then loadList End If For Each Item In FileList ' Performs a simple match on the filename, probably needs to be adjusted! If Item Like Name &amp; "*" Then Result = Item End If Next Item checkList = Result End Function ' populates the FileList collection Public Sub loadList() Dim FSO As Object Dim Folder As Object Dim File As Object If FileList Is Nothing Then ' First Run, needs to be created Set FileList = New Collection Else ' Should not happen unless you call it manually. Set FileList = Nothing ' Clear up the old list Set FileList = New Collection ' Create a new empty one End If Set FSO = CreateObject("Scripting.FileSystemObject") ' Change "C:\" to the location of the folder you want to search Set Folder = FSO.GetFolder("C:\") For Each File In Folder.Files ' Add the name to the FileList FileList.Add File.Name Next End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload