Sub 批次新建工作表() Dim i As Integer, iCount As Integer Dim str1 As String On Error Resume Next iCount = Application.InputBox(prompt:="請輸入新增工作表數量:", _ Title:="請輸入新增工作表數量", Type:=1) "設定新增工作表數量iCount If iCount > 0 Then For i = 1 To iCount Worksheets("Sheet1").Copy before:=Worksheets("Sheet1") "複製工作表sheet1並置於其前面 str1 = "sheet" & i "字首為MT也可以為字尾如: i & "MT" ActiveSheet.Range("A1") = str1 "將str1值賦給每個表的A1單元格 ActiveSheet.Name = str1 "將str1值賦給每個表的名稱 Next End If End Sub
Sub 批次新建工作表() Dim i As Integer, iCount As Integer Dim str1 As String On Error Resume Next iCount = Application.InputBox(prompt:="請輸入新增工作表數量:", _ Title:="請輸入新增工作表數量", Type:=1) "設定新增工作表數量iCount If iCount > 0 Then For i = 1 To iCount Worksheets("Sheet1").Copy before:=Worksheets("Sheet1") "複製工作表sheet1並置於其前面 str1 = "sheet" & i "字首為MT也可以為字尾如: i & "MT" ActiveSheet.Range("A1") = str1 "將str1值賦給每個表的A1單元格 ActiveSheet.Name = str1 "將str1值賦給每個表的名稱 Next End If End Sub