我使用以下代码复制我的Excel工作表(它弹出一个框,询问用户他们想要复制工作表的次数)
Sub Create()
'Updateby Extendoffice 20160704
Dim I As Long
Dim xNumber As Integer
Dim xName As String
Dim xActiveSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
Set xActiveSheet = ActiveSheet
xNumber = InputBox("Enter number of times to duplicate this sheet")
For I = 1 To xNumber
xName = ActiveSheet.Name
xActiveSheet.Copy After:=ActiveWorkbook.Sheets(xName)
ActiveSheet.Name = "dd-mm-yy" & I
Next
xActiveSheet.Activate
Application.ScreenUpdating = True
End Sub
我想excel VBA连续重命名工作表
要复制的工作表将始终是月份的开始" 01-01-17"我希望每张表都能相应地重命名," 02-01-17,03-01-17等"
答案 0 :(得分:2)
MSDN DateSerial Function (Visual Basic):返回表示指定年,月和日的日期值,时间信息设置为午夜(00:00:00)。
ActiveSheet.Name = Format(DateSerial(2017,I,1), "dd-mm-yy")