Rename or change the sheet name in excel UiPath

A lot of times we use excel to automate the business processes.

We get the input data for the automation through excel or we need to send the excel as output to business users.

Let’s say we have two sheets with different names when the input is received.

After processing it we need to rename the old sheet name of the input excel and share it with the business users.

Let us discuss the practical implementation of rename the old sheet name in input excel:

Step1: Drag and Drop an Excel Application Scope in the studio designer panel and provide the input excel path to it as shown below:

rename the sheet name

Step2: Drag and Drop an Invoke VBA Activity inside the excel application scope as shown below:

rename the sheet name

The different parameters that need to be set in Invoke VBA Activity are mentioned below:

rename the sheet name

Here:

  • CodeFilePath- Provide the file path where your code is saved.
  • EntryMethodName- The method name that is used in the file.
  • EntryMethodParameters- Provide the old sheet name and the new sheet name as shown above.

Let’s see the VBA code that we are using to rename the old sheet name in excel.

The is code is as follows:

Sub ChangeSheetName(SheetOldName As String, SheetNewName As String)
Sheets(SheetOldName).Name = SheetNewName
End Sub

Here:

  • ChangeSheetName – It is the method name.
  • SheetOldName- This is the old sheet name that is provided in parameters.
  • SheetNewName- This is the new sheet name that is provided in Parameters.

Now this will change the old sheet name to new sheet name in excel.

This is also can be achieved using the Microsoft 365 activities in the UiPath designer panel or use custom activities.

Happy Learning!

Like this post then let your friends know about this-:

Leave a Reply

Your email address will not be published. Required fields are marked *