Delete a sheet in excel?



how to delete a sheet in excel using uipath commands and save the file…


Hi @shrganes,

Please refer below post. @ddpadil



@shrganes, Refer this,
Delete Sheet

Dominic :slight_smile:


thank you…

i am able to delete it… but once i reopen the file the sheet still exists…how to over come that…??


Hi @shrganes,

Try After delete save the excel file. Using send hot key




what is the option for it… Ctrl S??


use Send hot Key activity

Alt + h then d and then ctrl + S





Alt F+S helps in saving the file


or ALT 1… helps in saving an excel file


Great then use the key to save the file.



Just in case anyone else comes upon this question, an easier way to do this is to just use the invoke code activity and use VB.NET to remove it.

You’ll need to add the Microsoft.Office.Interop.Excel reference if you don’t already have it.

Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook

xlApp = New Microsoft.Office.Interop.Excel.Application
wb = xlApp.Workbooks.Open(filepath)

xlApp.DisplayAlerts = False
TryCast(wb.Sheets(sheetname), Microsoft.Office.Interop.Excel.Worksheet).Delete()
xlApp.DisplayAlerts = True


This uses 2 string input arguments. filepath is the full file path of the workbook, including the extension. sheetname is the name of the worksheet you’d like to delete. This is the visible name of the worksheet NOT the VBA worksheet name defined in the VBA editing window.

I commonly need to delete just a single sheet, and just include it in a uipath loop if I need to remove more than one sheet. However, it’d be easy enough to modify the code yourself to loop through an array of strings that’s passed in for sheetname, or to loop through based on sheet index. If you do go the index route, make sure you delete from last to first because the index of later items will change if you start deleting from the beginning.

Delete a sheet in Excel