非常感谢您帮助我们解决这个小问题。
我想用我想要的名称多次复制一个excel工作表。我能够通过让它问我名字应该是什么来做到这一点 - 但是有没有办法通过编码那些20个左右的标签名称来做同样的事情。
这是我到目前为止所拥有的 -
Dim name As String
Dim x As Integer
x = ActiveWorkbook.Worksheets.Count
name = Application.InputBox("Put down the name", "Add worksheet")
If name = "" Then Exit Sub
Worksheets(1).Copy after:=Worksheets(x)
ActiveSheet.Name = name
请告诉我这是否可行。非常感谢您的帮助。
感谢。
答案 0 :(得分:0)
您可以插入一个模块with link provided here
它的要点是做到以下几点:
Click Insert > Module, and paste the following code in the Module Window.
Sub Copier ()
Dim x As Integer
x = InputBox("Enter number of times to copy Sheet1")
For numtimes = 1 To x
ActiveWorkbook.Sheets("Sheet1").Copy _
After:=ActiveWorkbook.Sheets("Sheet1")
Next
End Sub
答案 1 :(得分:0)
你需要做一个循环。
Dim ws As Worksheet
Set ws = Worksheets("WorksheetWithNames")
Dim y As Integer
For y = 1 To 10 ' < enter the number of sheets you want.
'copy the sheet
'rename the sheet
'assuming you have names in column A
ActiveSheet.Name = ws.Cells(y, 1)
Next