How to rearrange Excel Sheets in specific order

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

5 Likes