[英]Get last modified date of file excel
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 . 我想获得我需要在Excel的A列中输入的给定文件列表的最后修改日期。 How can I fix this ?
我怎样才能解决这个问题 ? For each file , I want to get the last modified date.
对于每个文件,我想获取最后修改日期。 Unfortunately I haven't many skills in VBA .
不幸的是,我在VBA中没有很多技能。
That's easy! 这很容易! You can apply
FileDateTime ( file_path )
. 您可以应用
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. 如果您在A列中有文件补丁和名称列表,并且此宏将返回在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
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. 您必须将“ A”和“ B”替换为该列的编号,并且如果知道有多少行,则可以简化。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.