我遇到错误" Worksheeet类的复制方法失败"在这一行:
.Sheets("Blank Forecast Sheet").Copy After:=.Sheets("Button Sheet")
我环顾四周,无法找到任何解决方案。可以看出,这段代码应该添加我将重命名的新工作表,一旦我解决了这个问题。
Sub addnewsheet()
Dim wbook As Workbook
Set wbook = Application.ActiveWorkbook
Dim newsheet As Worksheet
Dim datasheet As Worksheet
Dim m As String
Dim y As Integer
m = Format(Date, "mmmm")
y = Format(Date, "yyyy")
With wbook
.Sheets("Blank Forecast Sheet").Copy After:=.Sheets("Button Sheet")
End With
End Sub
答案 0 :(得分:0)
使用ThisWorkbook
代替wbook
和.Worksheets
代替.Sheets
:
Sub addnewsheet()
Dim newsheet As Worksheet
Dim datasheet As Worksheet
Dim m As String
Dim y As Integer
m = Format(Date, "mmmm")
y = Format(Date, "yyyy")
With ThisWorkbook
.Worksheets("Blank Forecast Sheet").Copy After:=.Worksheets("Button Sheet")
End With
End Sub