Return to VBA Code Examples

VBA FileDateTime Function

FileDateTime Description

Returns the date and time of when a file was created or last modified.

Simple FileDateTime Example

Assume a file “D:\test.txt” was last modified on 10/21/2019 9:41:30 AM .

This will return 10/21/2019 9:41:30 AM.

FileDateTime Syntax

In the VBA Editor, you can type  “FileDateTime(” to see the syntax for the FileDateTime Function:

The FileDateTime function contains an argument:

PathName: A string expression representing a file/folder/drive.

Examples of Excel VBA FileDateTime Function

To list the last modified time of the folder&files on C drive, you can use the following code.

The result will be similar with the following.

 

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!