用VBA代码循环表格当前目录下的所有Excel文件中修改日期为最新的文件名
Dim strPath As String
Dim strFile As String
Dim datLast As Date
Dim strLastFile As String
Set fso = CreateObject("Scripting.FileSystemObject")
Path = CurrentProject.Path & ""
strFile = Dir(Path & "*.xls")
strLastFile = ""
datLast = #1/1/1900#
Do While strFile <> ""
Set f = fso.Getfile(Path & strFile)
If f.DateLastModified > datLast Then datLast = f.DateLastModified: strLastFile = strFile
strFile = Dir
Loop
Msgbox "最新的文件" & strFile
有空闲时会定期发布些VBA免费教程,如能帮到您,请点个赞或给个回复,让我们继续前行。
Dim strPath As String
Dim strFile As String
Dim datLast As Date
Dim strLastFile As String
Set fso = CreateObject("Scripting.FileSystemObject")
Path = CurrentProject.Path & ""
strFile = Dir(Path & "*.xls")
strLastFile = ""
datLast = #1/1/1900#
Do While strFile <> ""
Set f = fso.Getfile(Path & strFile)
If f.DateLastModified > datLast Then datLast = f.DateLastModified: strLastFile = strFile
strFile = Dir
Loop
Msgbox "最新的文件" & strFile
有空闲时会定期发布些VBA免费教程,如能帮到您,请点个赞或给个回复,让我们继续前行。