简体   繁体   English

获取文件excel的最后修改日期

[英]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.

相关问题 Excel宏以查找文件的最后修改日期 - Excel Macro to find last modified date of file Excel VBA通​​过多个文件扩展名和上次修改日期获取文件列表 - Excel VBA to get a file list by multiple file extensions and last modified date 如何使用 VBA 从 Sharepoint 获取 Excel 文件的上次修改日期? - How to Get Last Modified Date of excel file from Sharepoint using VBA? 如何在Excel 2010中使用VBA在目录中获取最后修改的文件 - How to get the last modified file in a directory using VBA in Excel 2010 VBA - 如何在 Excel 2010 的目录中获取最后修改的文件或文件夹 - VBA - How to get the last modified file or folder in a directory in Excel 2010 如何使用 VBA 在 SharePoint 中获取文件的上次修改日期? - How will I get the last modified date of a file in a SharePoint using VBA? 如果文件的最后修改日期是今天,如何将Excel文件导入Pandas? - How do I import an Excel file to Pandas if the file's last modified date is today? SSIS:使用文件上次修改日期条件将数据从excel导入到sql server数据库 - SSIS: import data from excel to sql server database with file last modified date condition 获取带有MILLISECONDS的文件的最后修改日期? - Obtain the last modified date of a file with MILLISECONDS? Excel VBA Count文件在日期之前最后修改 - Excel VBA Count files last modified before date
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM