vba如何把excel表格复制到新表中,vba怎么复制excel表格

首页 > 实用技巧 > 作者:YD1662023-11-17 05:39:33

Sub Copysheets_To_file()

Dim Path,file, year, Month, day As String

year = Format(Date, "YYYY")

Month = Format(Date, "MM")

' day = day(Date)

Path = ThisWorkbook.Path & "\" '打开的EXCEL文件所在的目录

file = "XX电器" & year & "年" & Month & "月" & "考勤表.xlsx" '新的工作簿文件

Worksheets(Array("考勤表1", "考勤表2")).Copy ' "考勤表1", "考勤表2"为工作表

Set wbNew = ActiveWorkbook

With wbNew

ActiveWorkbook.SaveAs filename:=Path & file

.Close

End With

End Sub

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.