我试图用名称创建新工作表但遇到问题

时间:2020-05-15 20:27:32

标签: excel vba

Sub AddSheet()

Dim wkbSource As Workbook
Dim ws As Worksheet
Application.Screenupdating = False
Set wkbSource = Workbooks.Open("C:\nani\Excel-Vba\test.xlsx")

Set ws = wkbSource.Sheets

ws.Add(Before:=Sheets(1)).Name = "FirstSheet"


End Sub

1 个答案:

答案 0 :(得分:2)

很多问题

Sub AddSheet()

Dim wkbSource As Workbook
Dim ws As Worksheet

Set wkbSource = Workbooks.Open("C:\nani\Excel-Vba\test.xlsx")

Set ws = wkbSource.Worksheets.Add(Before:= wkbSource.Sheets(1))
Ws.Name = "FirstSheet"

End Sub