How do I clear a range of cell values in Blue Prism?

Mini K

New Member
Hi ,

I want to clear a range of cell values in Excel, Cannot delete the rows because I need the row numbers as it is.
Please help. TIA
 

sivagelli

Well-Known Member
In your Excel VBO object, add a new page and name it as "Clear Contents in range"

Add a Code stage on to the page with
  • Input parameters: Handle, Workbook, Worksheet, celref
  • Output Parameters: Success, Message
  • Add the below code in the code tab

Code:
Dim wb, ws As Object
Dim excel, sheet, range As Object

Try

wb = GetWorkbook(Handle, Workbook)
ws = GetWorksheet(Handle, Workbook, Worksheet)

wb.Activate()
ws.Activate()
excel = ws.Application
sheet = excel.ActiveSheet

sheet.Range(celref).ClearContents

Success = True

Catch e As Exception
    Success = False
    Message = e.Message
Finally
    wb = Nothing
    ws = Nothing
    excel = Nothing
    sheet = Nothing
    range = Nothing
End Try
The Start Stage on the page should accept the parameters: Handle, Workbook, Worksheet, celref
The End Stage on the page should send the parameters: Success, Message

Publish this page and Save.

Now, you are good to use the above action 'Turn Off AutoFilter'.

Flow would be:
1. Start
2. Create Instance
3. Open Workbook
4. Activate Workbook
5. 'Clear Contents in range' and pass the inputs- handle, workbook name, worksheet and Celref on which you want to remove content
6. Close workbook with Save set to True
7. Close Instance with Save set to True
8. End
 

mattrpa

New Member
Hi, i have one issue using this code.
the error is Internal : Could not execute code stage: Parameter count mismatch.

any help?

thanks a lot
 

Kanimozhi

New Member
Hi,
I am getting below error. Please help me to resolve.
GetWorkbook is not declared. It may be inaccessible due to its protection level.
 

ramsuratkumar

New Member
Hi, i have one issue using this code.
the error is Internal : Could not execute code stage: Parameter count mismatch.

any help?
 

mas nugi

New Member
Hi,
I want delete every row in excel if they match specific word at their column, do you have any code to solve this problem,
Thank you in advance.
 
Top