|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
请测试:
Private Sub CommandButton1_Click()
Dim arr, sh As Worksheet
arr = Range("b5:b" & Range("b65536").End(xlUp).Row - 1)
shtNum = Application.InputBox("请输入复制工作表的张数", Type:=1)
If shtNum = 0 Then Exit Sub
If shtNum > UBound(arr) Then shtNum = UBound(arr)
Application.ScreenUpdating = False
On Error Resume Next
With ThisWorkbook.Worksheets("样表")
For i = 1 To shtNum
Set sh = Sheets(arr(i, 1))
If sh Is Nothing Then
.Copy After:=Sheets(ThisWorkbook.Worksheets.Count)
ActiveSheet.Name = arr(i, 1)
End If
Set sh = Nothing
Next i
End With
Application.ScreenUpdating = True
End Sub
[ 本帖最后由 zhaogang1960 于 2010-1-19 16:54 编辑 ] |
|