Sub Test()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Worksheets("Sample1")
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub
However, the problem is whenever I change sheet name, the code wouldn't run anymore. So I decide to use the sheet codename which is Fixedtemplate(template)
Sub Test()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Fixedtemplate
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub
There is still
compile error: Method or data member not found
The code works below for me, you will need to provide either the name or the number of the sheet in order to copy the data.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.