NativeExcel for .Net Developer's Reference

IWorksheet.MoveMethod

Moves the sheet to another location in the workbook.

[Visual Basic]
SubMove(_
ByValBeforeAsObject,_
ByValAfterAsObject_
)
[C#]
voidMove(
objectBefore,
objectAfter
);
[C++]
voidMove(
Object*Before,
Object*After
);
[JScript]
functionMove(
ObjectBefore,
ObjectAfter
);

Parameters

Before
An object that specifies the worksheet before which the moved sheet will be placed. Can be either an IWorksheet interface, Number which indicates the worksheet index or String which indicates the worksheet name. You cannot specify Before if you specify After.
After
An object that specifies the worksheet after which the moved sheet will be placed. Can be either an IWorksheet interface, Number which indicates the worksheet index or String which indicates the worksheet name. You cannot specify After if you specify Before.

Example

This example moves the first worksheet after the third in the workbook.

[C#]
book.Worksheets[1].Move(null, 3); 
[VisualBasic]
book.Worksheets(1).Move(Nothing, 3) 
[C++]
book->Worksheets->Item[1]->Move(null, 3);
This example moves the second sheet before the worksheet Sheet5 in the workbook.
[C#]
book.Worksheets[1].Move("Sheet5", null); 
[VisualBasic]
book.Worksheets(1).Move("Sheet5", Nothing) 
[C++]
book->Worksheets->Item[1]->Move(S"Sheet5", null);

See Also

IWorksheet Interface | NativeExcel Namespace