Excel VBA Date File Created

The following Excel VBA procedure shows how you can create a list of the files in a folder and the date these files were created.  The procedure lists the files in descending order from when they were created.

The following is how the files is set up with the file path on the right.  Change the file path to the path which is most relevant for your requirements.

Date File created vba

The following is the Excel VBA which drives the procedure.  It uses a simple loop to generate the file names and uses these names in conjunction with the file system object to search the directory for the date created.

OptionExplicit

Sub GetDateCreated() 'Excel VBA to list date created.
Dim sPath As String
Dim oFS As Object
Dim i As Integer
Dim sFil As String

sPath=[G6].Value'Changetosuit
sFil=Dir(sPath& "*.xl*") 'xl here adds flexibility
SetoFS=Createobject("Scripting.FileSystemObject")
i=7

Do While sFil <> "" 'Loop through the files in the directory
Range("B65536").End(xlUp)(2).Value=sPath& sFil
Range("C" & i)=oFS.GetFile(Range("B" & i)).DateCreated
sFil=Dir
i=i+ 1
Loop
Range("A2", Range("B" & Rows.Count).End(xlUp)).Sort [b2], 2
EndSub

The following Excel file shows the above example with the relevant VBA coding.