How to: Move Worksheets Within Workbooks
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

How to: Move Worksheets Within Workbooks


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 Move method works much like the Copy method in Microsoft Office Excel 2003, except that you end up with only one instance of the sheet. If you do not specify a location for the moved sheet, Excel creates a new workbook to contain it.

To move a worksheet

  • Assign the total number of sheets in the workbook to a variable and then move the first worksheet so that it becomes the last one.

    int totalSheets = this.Application.ActiveWorkbook.Sheets.Count;
    Globals.Sheet1.Move(missing, Globals.ThisWorkbook.Sheets[totalSheets]);

If you want to sort the list of sheets in a workbook, you can make use of the Move method to perform a bubble sort.

See Also

© 2016 Microsoft