Delete Specific Sheet From workbook

Hi Folks,

How to delete the specific workbook sheet in excel in UiPath?

The Sheet name is “Sheet1”.

Thanks in advance.

Regards,
Sharu

Hi @sharu_priya ,

Use Delete sheet activity.

https://docs.uipath.com/activities/other/latest/user-guide/delete-sheet-x

image

Regards,
Arivu

1 Like

Yeah i saw this.

But i do not have this activity in m studio.

Which package needs to be installed for this?

Regards,
Sharu

Delete Sheet Activity is not Showing in modern also

UiPath.Excel.Activities

Its already there

Hi @sharu_priya

Please try to this macro:

Sub DeleteSheet()
    Dim sheetName As String
    sheetName = "Sheet1"
    Application.DisplayAlerts = False
    Worksheets(sheetName).Delete
    Application.DisplayAlerts = True
End Sub

Hope this helps,
Best Regards

Hi @sharu_priya ,

You can use excel VBA as well to delete the sheet:

Inside the excel application scope, insert the invoke vba.

Sub vba_delete_sheet()
Sheets(“SheetName”).Delete
End Sub

Regards,

Thank you @vishal.kp

Can you please elaborate?

Is modern activity enabled?

Yes, it is enabled

@sharu_priya , check this:

BlankProcess10.zip (8.6 KB)

Regards,

1 Like

Thank you so much.will Try now

Hi @sharu_priya

To delete a specific worksheet named “Sheet1” in UiPath, you can follow these steps:

  1. Use the “Excel Application Scope” activity to open the Excel workbook that contains the sheet you want to delete.
  2. Drag a “Invoke VBA” activity inside the “Excel Application Scope” activity.
  3. In the “Invoke VBA” activity, paste the following code in the “CodeText” field:

Sub DeleteSheet()
Application.DisplayAlerts = False
ThisWorkbook.Sheets(“Sheet1”).Delete
Application.DisplayAlerts = True
End Sub

  1. Save and close the VBA Editor.
  2. In the “Invoke VBA” activity, set the “MethodName” property to “DeleteSheet”.
  3. Run the UiPath workflow and the “Sheet1” worksheet should be deleted from the Excel workbook.

Hi,

Thank You.

Code Text Field is not visible.

@sharu_priya
Write the vba code in a file and provide that file location in a vba source code file path.

Set the “vba source code file path” property to the full path of the Excel workbook that contains the macro code i shared above

it Worked.

Thank you so much.

1 Like

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