Delete a Sheet from a Excel

Hi
Trying to delete a sheet from a Excel which contains Data,I am deleting the sheet through vb.net,here when the sheet is empty it is deleting,when it is non empty the sheet is not get deleted,

please suggest me with this
please verify code i have used

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb = excel.Workbooks.Open(newfile)

ws=CType(wb.Sheets(“Sheet2”),Microsoft.Office.Interop.Excel.Worksheet)
ws.Delete()
wb.Save()
wb.Close()
excel.Quit()

Thanks & Regards,
A Manohar

Hi @Manohar1,

Please use the Delete Sheet activity.

To get that activity, please install this package: BalaReva.Excel.Activities
image

Hope this helps.
Thanks and regards,
Despi

Hi @Jan_Brian_Despi

Thanks ,Its working…

Good to hear that!
Feel free to approach me anytime :slight_smile: