Sub Test()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Worksheets("Sample1")
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub
但是,问题是每当我更改工作表名称时,该代码就不再运行。所以我决定使用工作表的代号,它是Fixedtemplate(template)
Sub Test()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Fixedtemplate
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub
还有
编译错误:未找到方法或数据成员
答案 0 :(得分:-1)
以下代码对我有用,您需要提供工作表的名称或编号才能复制数据。
Sub main()
Call Copydata("Fixedtemplate")
End Sub
Sub Copydata(name As String)
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets(name)
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub