Hi, I want to copy all the file names in a folder to a excel sheet but I only want to copy the files that end in .xlsx. I think I need to add *.xlsx* to the "Set myFolder [...]" line but I am not sure of the syntax.
This is the code that I have so far
Sub GetFilesDetails()
Dim objFSO As Scripting.FileSystemObject
Dim myFolder As Scripting.Folder
Dim myFile As Scripting.File
Dim R As Long
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = objFSO.GetFolder("X:\Outgoing Purchase Orders\2018\")
Application.ScreenUpdating = False
R = 2
For Each myFile In myFolder.Files
ThisWorkbook.Sheets("Sheet1").Cells(R, 1).Value = myFile.Name
ThisWorkbook.Sheets("Sheet1").Cells(R, 2).Value = myFile.DateCreated
R = R + 1
Next myFile
End Sub
Any help is much appreciated!
P.S I gave the thread the wrong name but now I can't figure out how to rename thread, or delete thread and re-do with correct title.
This is the code that I have so far
Sub GetFilesDetails()
Dim objFSO As Scripting.FileSystemObject
Dim myFolder As Scripting.Folder
Dim myFile As Scripting.File
Dim R As Long
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = objFSO.GetFolder("X:\Outgoing Purchase Orders\2018\")
Application.ScreenUpdating = False
R = 2
For Each myFile In myFolder.Files
ThisWorkbook.Sheets("Sheet1").Cells(R, 1).Value = myFile.Name
ThisWorkbook.Sheets("Sheet1").Cells(R, 2).Value = myFile.DateCreated
R = R + 1
Next myFile
End Sub
Any help is much appreciated!
P.S I gave the thread the wrong name but now I can't figure out how to rename thread, or delete thread and re-do with correct title.