Delete excel work sheet

Hi All, How to delete excel sheet using VBA or VBScript.

My sheet name and file name changes every time i want to pass arguments for that. can anyone suggest me how to do.
i tried few VBA and VBS scripts but i’m getting error.

Note : My system won’t accept 3rd party packages

Hi @Learner007

Refer the video link


1 Like

Hi @Learner007 ,

Use invoke code activity and create one argument for sheet name to delete. Please find the below code. don’t forget to include the Microsoft.Office.Interop.Excel namespace. please try and let us know. thanks.

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb1 = excel.Workbooks.Open(WorkBookPath)
ws1 = CType(wb1.Sheets(SheetToDelete), Microsoft.Office.Interop.Excel.Worksheet)
wb1.Application.DisplayAlerts = False
wb1.Application.DisplayAlerts = True
ws1 = Nothing
wb1 = Nothing
excel = Nothing

Thanks @kirankumar.mahanthi1 it’s working

@Gokul001 this one i tried but got some error in final another code is working fine for me

Your welcome @Learner007

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