This macro will allow you to pull file names from a specific folder. This is especially helpful when you have several research projects which involves file names (order numbers, loan numbers, client name, etc). Just copy-paste the code below into the VBA Module.
CODE:
Sub ObtainFileName()
'Obtain file names from a folder
'Learnwithglezy.com
Dim SysObj As Object
Dim Folder As Object
Dim FileName As Object
Dim i As Integer
Set SysObj = CreateObject("Scripting.FileSystemObject")
Set Folder = SysObj.GetFolder("C:\Users\FolderLocationSample\") 'Change this to folder location
'cells( i + 1 ,1) this just represents which column filenames will be dropped
For Each FileName In Folder.Files
Cells(i + 1, 1) = FileName.Name
i = i + 1
Next FileName
End Sub
Comments