tizzodizzo
Programmer
I am trying to copy just the names of a file from a directory and patse it into different cell within excel. I don't need anything from with-in the file. I just need the name of the file. Can anyone Help?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Returns a String representing the [blue]name of a file[/blue], directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive.
Syntax
Dir[(pathname[, attributes])]
Public Sub ListAllFiles()
Dim FName As Variant
Dim i As Integer
i = 0
FName = Dir("C:\My Documents\*.xls", vbNormal)
While FName <> ""
i = i + 1
ActiveSheet.Cells(i, 1).Value = FName
FName = Dir()
Wend
End Sub