How to: Add New Worksheets to Workbooks
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Add New Worksheets to Workbooks

NoteNote

Some code examples in this topic use the this or Me keyword or the Globals class in a way that is specific to document-level customizations, or they rely on features of document-level customizations such as host controls. These examples can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination.

The Add method enables you to add a new worksheet to the collection of worksheets in the workbook. However, when you add the worksheet programmatically, the new worksheet is a native Microsoft.Office.Interop.Excel.Worksheet object that contains native Excel objects without any data-binding capabilities, events, or code. If you want to add a Microsoft.Office.Tools.Excel.Worksheet host item, you should add the worksheet at design time. For more information, see Programmatic Limitations of Host Items and Host Controls.

You can also create a copy of an existing worksheet. For more information, see How to: Copy Worksheets.

To add a new worksheet to a workbook

  • Use the Add method of the Sheets collection:

    Excel.Worksheet newWorksheet;
    newWorksheet = (Excel.Worksheet)Globals.ThisWorkbook.Worksheets.Add(
        missing, missing, missing, missing);
    
    

See Also

Show:
© 2016 Microsoft