How to clear all the contents in an excel sheet UiPath
A lot of times while designing process automation we use excels as input or output.
While using excels as a data source we might need to clear all the contents in excel after completing the process execution.
For completing this task there are several ways but we are using vba.
Let’s get into the practical implementation of this task:
Step1: The input in the excel that we are using for this example is shown below:
![input excel values](https://rpalearners.com/wp-content/uploads/2021/06/excelcellformulauipath.jpg)
Step2: Drag and Drop an excel application scope activity from activities panel to designer panel as shown below:
![excel application scope](https://rpalearners.com/wp-content/uploads/2021/03/excelapplicationscope-3.jpg)
Step3: Drag and Drop Invoke VBA activity from activities panel to designer panel as shown below:
![clear all the contents](https://rpalearners.com/wp-content/uploads/2021/06/clearsheetvba.jpg)
Let’s see the required properties for invoke vba activity:
![clear all the contents](https://rpalearners.com/wp-content/uploads/2021/06/clearsheetpropvba.jpg)
- CodeFilePath – Provide the file path where your VBA code is present.
- EntryMethodName – Mention the method name that is used in the VBA code.
- EntryMethodParameters – If you are passing any input values to vba code those can be mentioned here.
- OutputValue – If the code is returning some value then it can be assigned here.
The VBA code that is used to clear all the contents of an excel file is shown below:
Sub ClearSheet()
Sheets("Sheet1").Cells.Clear
End Sub
Here sheet1 is the sheet name where we are clearing the entire data.
This is one way of achieving this task.