How to rearrange Excel Sheets in specific order

Hi, I have an excel sheets with order eg. “A”, “C”,“B”
Is there a way to reorder it in a way I want eg. “A”, “B”, “C”

& preferably without creating a new excel file

Here you go buddy @inyourgravity
Its resolved
arrange (8.8 KB)


Thanks but I would like to rearrange within the same excel file instead of creating a new file.

And is there a way I can set the order of sheets instead or sort by ascending.
The case is the sheet names I want to sort will not be sorted in ascending order

i think we need to go for developing a custom activity fr this as even the one we have in uipath custom package doesn’t have option
Thats why i tried with the above once
Cheers @inyourgravity


You can achieve it by executing a macro.
Below code works perfect to arrange sheets alphabetically :slight_smile:,

Sub SheetsAscending()
For i = 1 To Application.Sheets.Count
For j = 1 To Application.Sheets.Count - 1
If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
Sheets(j).Move after:=Sheets(j + 1)
End If
MsgBox “The tabs have been sorted from A to Z.”

End Sub

1 Like

I have actually managed to do it with invoke code :slight_smile:

Dim xlApp As Microsoft.Office.Interop.Excel._Application = Nothing Dim xlWorkBooks As Microsoft.Office.Interop.Excel.Workbooks=Nothing Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook=Nothing Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet=Nothing Dim xlWorkSheets As Microsoft.Office.Interop.Excel.Sheets=Nothing xlApp=New Microsoft.Office.Interop.Excel.ApplicationClass xlApp.DisplayAlerts=False xlWorkBooks=xlApp.Workbooks xlWorkBook=xlWorkBooks.Open(filepath) xlApp.Visible = True xlWorkSheets=xlWorkBook.Sheets xlWorkSheet= CType(xlWorkSheets(sheetname),Microsoft.Office.Interop.Excel.Worksheet) xlWorkSheet.Move(Before:=xlWorkBook.Worksheets(1))

This will move a specific sheetname in filepath to index 1 in excel


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

Hi ,

To rearrange the sheet you can able to use this activity.