Revision: 70820
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 22, 2016 19:51 by cueballrawn
Initial Code
Sub ListAllFile() Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Dim ws As Worksheet Set objFSO = CreateObject("Scripting.FileSystemObject") Set ws = Worksheets.Add 'Get the folder object associated with the directory Set objFolder = objFSO.GetFolder("C:\") ws.Cells(1, 1).Value = "The files found in " & objFolder.Name & "are:" 'Loop through the Files collection For Each objFile In objFolder.Files ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = objFile.Name Next 'Clean up! Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub
Initial URL
http://www.ozgrid.com/forum/showthread.php?t=65530
Initial Description
Lists all filenames in a directory if you need them for formulae or add into VBA.
Initial Title
Excel (VBA) list all filenames in a directory
Initial Tags
excel
Initial Language
Visual Basic