I would like to get the last modified date of a given list of files that I need to enter in column A of Excel . How can I fix this ? For each file , I want to get the last modified date. Unfortunately I haven't many skills in VBA .
-
2Welcome at stackoverflow, unfortunately it's not a free code writing service. You need to start learning to write code and we're happy to help you during that. If you don't wish to learn it then best option is probably to hire somebody to do it for you.Máté Juhász– Máté Juhász2015-09-02 08:26:10 +00:00Commented Sep 2, 2015 at 8:26
Add a comment
|
2 Answers
That's easy! You can apply FileDateTime ( file_path ). If you have file patch & name list in column A, and this macro will return the date & time of when a file was created or last modified in column B.
Sub LastFileDateTime()
CNT = Range("A65536").End(xlUp).Row
For i = 1 To CNT
Cells(i, "B").Value = FileDateTime(Cells(i, "A"))
'FileDateTime("D:\QueryTable.xlsm")
Next
End Sub
2 Comments
Riccardo Dell'Omo
Unfortunately it doesn't work ! The file path is not taken and appears #VALUE !
SY Chen
Any more detail information? Please check the file path like this D:\QueyTable.xlsm.
You have to replace "A" and "B" with the number for the column, and you can simplify if you know how many rows you have. I was able to get it to work with the code below.
Sub LastFileDateTime()
For i = 2 To 45
Cells(i, 2).Value = FileDateTime(Cells(i, 1))
'FileDateTime("D:\QueryTable.xlsm")
Next
End Sub