Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Move-OfficeExcelSheet

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelSheet

Moves a worksheet to a one-based workbook position.

Syntax

Move-OfficeExcelSheet
[-Document <ExcelDocument>]
[-PassThru]
[-Position] <Int32>
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]
#
Parameter set: Default

Description

Uses the explicit or enclosing live workbook. Save it explicitly to persist the new order.

Examples

Move the summary worksheet to the front.

$book | Move-OfficeExcelSheet -Sheet Summary -Position 1
Save-OfficeExcel -Document $book

Move a sheet to the front

Open-OfficeExcel -Path .\Reports\Q3-Sales.xlsx {
    Move-OfficeExcelSheet -Sheet Summary -Position 1
}

Moves the Summary sheet to the first tab position.

Order monthly sheets newest first

$book = Open-OfficeExcel -Path .\Reports\Tickets-2026.xlsx
foreach ($month in 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October') {
    Move-OfficeExcelSheet -Document $book -Sheet $month -Position 1
}
Save-OfficeExcel -Document $book -PassThru | Close-OfficeExcel

Moves the sheet for each month to the front in turn, so the most recent month ends up first.

Parameters

-Document ExcelDocument optionalpipeline: True (ByValue)
Gets or sets an explicit live document; omission uses the enclosing content block.
-PassThru SwitchParameter optional
Gets or sets whether to return the moved native worksheet.
-Position Int32 requiredposition: 0
Gets or sets the one-based destination position.
-Sheet OfficeSheetSelector optionalaliases: WorksheetName
Gets or sets a worksheet name, one-based position or native worksheet.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.