3

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 .

1
  • 2
    Welcome 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. Commented Sep 2, 2015 at 8:26

2 Answers 2

5

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
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately it doesn't work ! The file path is not taken and appears #VALUE !
Any more detail information? Please check the file path like this D:\QueyTable.xlsm.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.