|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim ar, br, i&, j&, n, strPath$, strFileName$, wks As Worksheet
n = InputBox("请输入9的整数倍", "", 2)
If Val(n) = 0 Then Exit Sub Else n = Val(n)
strPath = ThisWorkbook.Path & "\"
With Application.FileDialog(4)
.InitialFileName = strPath
.AllowMultiSelect = True
If .Show Then
If Right(.SelectedItems(1), 1) = "\" Then
strPath = .SelectedItems(1)
Else
strPath = .SelectedItems(1) & "\"
End If
Else
Exit Sub
End If
End With
Application.DisplayAlerts = False
ReDim ar(1 To n * 9)
br = Array("", "A", "B")
With Workbooks.Add
strFileName = strPath & "生成"
For i = 0 To UBound(br)
For j = 1 To n * 3
With .Worksheets.Add(after:=.Worksheets(.Worksheets.Count))
.Name = j & br(i)
End With
Next j
Next i
For Each wks In .Worksheets
If wks.Name Like "*Sheet*" Then wks.Delete
Next
.SaveAs strFileName
.Close
End With
Application.DisplayAlerts = True
End Sub
|
|