excl怎样在一个工作表中建立快速多个子工作表并且重命名?

2024-12-21 22:23:27
推荐回答(1个)
回答1:

新建一个excel文件,按alt+F11,在左边点右键,插入,模块,双击模块,粘贴下面的代码。
然后按F5,运行新建宏。输入张数,
很快就建立完成了。
Sub 新建()
Dim arr, sh As Worksheet
shtNum = Application.InputBox("请输入复制工作表的张数", Type:=1)
If shtNum = 0 Then Exit Sub
Application.ScreenUpdating = False
On Error Resume Next
Application.DisplayAlerts = False
Workbooks.Add
With ActiveWorkbook
For i = 1 To shtNum
.Sheets.Add after:=.Sheets(.Sheets.Count)
ActiveSheet.Name = "2011-6b-" & i
Next i
End With
Application.ScreenUpdating = True
End Sub