Hi Alakar
Here is the solution, use this code, It works perfect, I ran it.
Please note portions of code in RED are the ones you can change to suit your needs
Please check your folder path is correct
You must click Microsoft Scripting Runtime on VBA panel as shown below
This is the macro
''*******************************************************************
Sub GetFilesDetails()
' This macro will extract the list of the filenames from a folder as follows
' in column A= Files names
' in column B= Date Created
' in column C= Date Last Accessed
' in column D= Date Last Modified
Dim objFSO As Scripting.FileSystemObject
Dim myFolder As Scripting.Folder
Dim myFile As Scripting.File
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = objFSO.GetFolder(“G:\S5GH\Global Finance Hub\Client Management\TORM OWNERS\Processing\PO Related Files\Cancelled\”)
Application.ScreenUpdating = False
''******************************************************************************
' these 2 code lines will clear the old data in Sheet? from columns A:D
' Row 1 is for the appropriate headers only
ThisWorkbook.Sheets("Sheet1").Range(Cells(2, 1), Cells(Rows.Count, 4)).ClearContents
R = 2
''********************************************************************
' Here we get the files details from folder and place them in the appropriate cells
For Each myFile In myFolder.Files
ThisWorkbook.Sheets("Sheet1").Cells(R, 1).Value = myFile.Name
ThisWorkbook.Sheets("Sheet1").Cells(R, 2).Value = myFile.DateCreated
ThisWorkbook.Sheets("Sheet1").Cells(R, 3).Value = myFile.DateLastAccessed
ThisWorkbook.Sheets("Sheet1").Cells(R, 4).Value = myFile.DateLastModified
R = R + 1
Next myFile
'''************Resizing the columns width****************
ThisWorkbook.Sheets**("Sheet1").Columns("A:D**").EntireColumn.AutoFit
Application.ScreenUpdating = True
'' Optional Alert
MsgBox "Updated"
End Sub
*********************************************************************************
Note2
To run the macro automatically please do as follow in images
Select the Sheet where you want the filename to be listed ie. Sheet1 from the VBA panel
and access to the code of the sheet and select Worksheets and on the procedures Activate
and Call the macro as shown in picture bellow
****This will run the macro automatically every time you select the sheet1
This will be the result on Sheet1 after running the macro
Hope this will help you, Please click as answered of so. I will appreciate it
Thanks
Regards
Jeovany CV