Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Move Worksheets Within Workbooks

Updated: July 2008

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Excel 2003

  • Excel 2007

For more information, see Features Available by Application and Project Type.

You can programmatically change the position of worksheets relative to other worksheets in a workbook. If you do not specify a location for the moved sheet, Excel creates a new workbook to contain it.

To move a worksheet in a document-level customization

  • 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]);
    

To move a worksheet in an application-level add-in

  • 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;
    ((Excel.Worksheet)Application.ActiveSheet).Move(missing, 
        this.Application.Worksheets[totalSheets]);
    

Date

History

Reason

July 2008

Added a code example that can be used in an application-level add-in.

Customer feedback.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft