文章预览
学习Excel技术,关注微信公众号: excelperfect 下面的代码收集自vbaexpress.com,可以将源文件夹中的最新文件复制到另一个文件夹。代码运行后,弹出一个对话框告诉用户选择源文件夹,选好后,单击“确定”,会弹出另一个对话框告诉用户选择目标文件夹,单击“确定”,源文件夹中的最新文件将被复制到目标文件夹中。 VBA代码如下: Dim FileNames() As Variant Dim FSO As Object Dim FileCounter As Long Const FinalFileName As String = "LastFile" '将这个名字修改为你实际的名字 Sub MoveRecentFile() Dim FD As FileDialog Dim IsSourceFolSelected As Boolean Dim IsTargetFolSelected As Boolean Dim SourceFolderPath As String Dim RecentDate As Date Dim RecentFileName As String Dim x As Long
………………………………