我想将当前工作表另存为桌面上具有日期和时间的新工作簿名称中的单独工作簿。
如何保存?
答案 0 :(得分:1)
我们可以使用下面的代码将当前工作表导出到桌面作为工作簿,其中包含日期和时间。
Sub Expo()
Application.ScreenUpdating = False
'Get path for desktop of user PC
Path = Environ("USERPROFILE") & "\Desktop"
Sheet1.Cells.Copy
'Create new workbook and past copied data in new workbook & save to desktop
Workbooks.Add (xlWBATWorksheet)
ActiveWorkbook.ActiveSheet.Paste
ActiveWorkbook.ActiveSheet.Name = "report"
ActiveWorkbook.SaveAs Filename:=Path & "\" & "report " & Format(CStr(Now()), "dd-mmm (hh.mm.ss AM/PM)") & ".xlsx"
ActiveWorkbook.Close SaveChanges:=True
Application.ScreenUpdating = True
MsgBox "Exported to Desktop"
End Sub