How to: Programmatically add new worksheets to workbooks
Applies to: Visual Studio Visual Studio for Mac Visual Studio Code
You can programmatically create a worksheet and then add the worksheet to the collection of worksheets in the workbook.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.
To add a new worksheet to a workbook in a document-level customization
Excel.Worksheet newWorksheet; newWorksheet = (Excel.Worksheet)Globals.ThisWorkbook.Worksheets.Add();
To add a new worksheet to a workbook in a VSTO Add-in
Excel.Worksheet newWorksheet; newWorksheet = (Excel.Worksheet)this.Application.Worksheets.Add();
The new worksheet is a native Worksheet object and not a host item. You can also generate a Worksheet host item from the native Worksheet object. For more information, see Extending Word Documents and Excel Workbooks in VSTO Add-ins at Run Time.
Submit and view feedback for