每天省出1小时,换个好心情
1.判断是否存在tempfolder (过渡文件夹)
2.不存在 则在目标目录下新建文件夹tempfolder
在网上看到一种更简单的方法
if dir("e:定单计划月度定单日计划") ="" then MkDIr "e:定单计划月度定单日计划"
3.将excel文件复制到tempfolder,本人筛选报表的关键字是"liyi",筛选条件
4.用name 对tempfolder 重命名
操作之前
Sub 报表打包()
On Error Resume Next
Dim a As String
a = "C:UsersAdministratorDesktop201605报表 empfolder"
If Len(Dir(a)) = Empty Then
Set tempfolder = CreateObject("scripting.filesystemobject")
tempfolder.createfolder ("C:UsersAdministratorDesktop201605报表 empfolder")
Else
MsgBox "tempfolder已经存在!"
End If
Dim foldername As String
Set fs = CreateObject("Scripting.FileSystemObject")
fs.copyfile "C:UsersAdministratorDesktop每日报表*liyi*.xls*", "C:UsersAdministratorDesktop201605报表 empfolder", True
'复制报表到tempfolderN
yue = Month(Date)
ri = Day(Date)
Name "C:UsersAdministratorDesktop201605报表 empfolder" As "C:UsersAdministratorDesktop201605报表 " & yue & ri
'文件夹更名
End Sub
运行宏之后的结果: