How to pass a variable to an "Invoke VBA" script?

Hi all,

I found on the forum a VB script that helps Clear entire excel sheet cells, using some VBA:

Sub clearEntireSheet()
End Sub

However, this script will only clear values in a sheet called “Sheet1”.

Question: how can I make “Sheet1” dynamic, and pass any string variable from my project to this VB script, so that it can clear any sheet name I provide to it?

Many thanks,

Hi @Stanciu_Nicu ,

You can pass any argument like this.

1 Like

Hi @Stanciu_Nicu,
You can use the scrpit modified like this

Sub clearEntireSheet(SheetName as String)
End Sub

In workflow use Invoke VBA activity where in EntryMethodName you have to use VBA’s name and in the Parameters you can pass the sheet name you want.

1 Like

change the vba code to this

Sub clearEntireSheet(sheetName As String)
End Sub

Then in uipath:
use invoke vba activity, under EntryMethodParameters pass in the sheet name you want to delete e.g. “Sheet5”

1 Like

Thank you all for quick and valuable input. Marking @jack.chan’s answer as the most complete one. It works!

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