VBA FileDateTime Function


- Written by Puneet


VBA FileDateTime function returns the last modified date and time (as a string) of a file (workbook).

You need to specify the address of the file as an argument.



Where the PathName argument is the path and filename of the file for which you want details.


In the below VBA code, we have used VBA FileDateTime to insert last modified date and time of a file from the desktop into the cell A1.

Sub modFile()
Range("A1").Value = FileDateTime("C:UsersPuneet GogiaDesktopBook1.xlsx")
End Sub

When you run this code it adds date and time just like below into the A1.

code with vba filedatetime example

Last Updated: March 24, 2024