更改新工作簿中的預設工作表數
在新的 Excel 工作簿中建立的出廠預設工作表數通常設定為 3。你的 VBA 程式碼可以顯式設定新工作簿中的工作表數。
'--- save the current Excel global setting
With Application
Dim oldSheetsCount As Integer
oldSheetsCount = .SheetsInNewWorkbook
Dim myNewWB As Workbook
.SheetsInNewWorkbook = 1
Set myNewWB = .Workbooks.Add
'--- restore the previous setting
.SheetsInNewWorkbook = oldsheetcount
End With