Hi all,
My query is how to delete an excel sheet in an excel I have 5sheets i need to delete sheet 2,3 and 4. I am using classic version.
Please help me thanks in advance
Hi all,
My query is how to delete an excel sheet in an excel I have 5sheets i need to delete sheet 2,3 and 4. I am using classic version.
Please help me thanks in advance
Inside the “Excel Application Scope,” add a “Invoke VBA” activity.
In the properties of the “Invoke VBA” activity, write the following VB.NET code to delete the sheets:
Sub DeleteSheets()
Dim xlApp As Object
Dim xlWorkBook As Object
Dim xlWorkSheet As Object
xlApp = CreateObject(“Excel.Application”)
xlWorkBook = xlApp.Workbooks.Open(“path_to_your_excel_file.xlsx”)
Try
xlWorkBook.Worksheets(“Sheet2”).Delete()
xlWorkBook.Worksheets(“Sheet3”).Delete()
xlWorkBook.Worksheets(“Sheet4”).Delete()
Catch ex As Exception
’ Handle any exceptions here if necessary
End Try
xlWorkBook.Save()
xlWorkBook.Close()
xlApp.Quit()
End Sub
Check the below video for better reference to delete the sheet in classic activities.
Hope it helps!!
Try this
or
Sub DeleteSheets()
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets("Sheet2").Delete
ThisWorkbook.Sheets("Sheet3").Delete
ThisWorkbook.Sheets("Sheet4").Delete
Application.DisplayAlerts = True
End Sub
Regards,
Use
Sub vba_delete_sheet()
Sheets("Data").Delete
End Sub
Regards,
Prasanth Kumar Manivannan
Battlebots!!
Thank you for helping me
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.