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.

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.


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

sFil=Dir(sPath& "*.xl*") 'xlhereaddsflexibility

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
i=i+ 1
Range("A2", Range("B" & Rows.Count).End(xlUp)).Sort [b2], 2

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