Passing Variable using through Invoke VBA activity

Hi All,
I Have a issue to pass a variable from UIpath to VBA Code. Can anyone help me on this . Please find the attached EntryMethodParameter images for your reference and the VBA Code in VBA_1.txt like Range(“C2”).Formula = “=FIND(”" +mnth+ “”,B2)" . And the Error message plz refer attached error image. (Note: the variable mnth is a string)
image
image

Hi
have we passed all the parameters to the property EntrymethodParameters
,i.e., if we have 5 parameters inside the script then we must have passed 5 parameters here in the property
Kindly check that once pls

Cheers @Subhass

Hi Palaniyappan,

Thanks for the quick reply.
I have only one Parameter. That is mnth. Am not sure,do I need to change the EntryMethodParameter or need to change in VBA Code.

Fine
may i know what is the datatype of that variable
@Subhass

It is a string Variable

1 Like

hi @Subhass

may this help you
Regards

awesome
can i have a view on the screenshot of the vb script if possible
@Subhass

Hello Fernando,

Thanks for the link. Am trying to find input methods in VBA Code.

Yah sure Palaniyappan,

The code as follows. I think something missing to assign and get the variable in my code

Sub MoveBeginning()
Dim LastRow As String
'Move the active sheet to the beginning
ActiveSheet.Copy after:=Worksheets(1)
ActiveSheet.Name = “PRIISM”
Columns(1).EntireColumn.Delete
Range(“B1”).Delete shift:=xlUp
Range(“A1”).EntireRow.Insert
Range(“A1”).Value = “Name”
Range(“B1”).Value = “Off”
Range(“B:B”).Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
''Range(“C2”).Formula = “=FIND(“Jun”,B2)”
Range(“C2”).Formula = “=FIND(”" +mnth+ “”,B2)"
Range(“C2”).Copy
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range(“C2:C” & LastRow).PasteSpecial xlPasteFormulas
With ActiveSheet.UsedRange
.Value = .Value
End With

End Sub

Hi,

as per function you have not created method parameter, so you have to add parameter in function like below.

Sub MoveBeginning(mnth as string)

Thanks,

1 Like

Now It is working fine. Thanks a lot Sunil

Thanks for the guidance Palaniyappan :slight_smile:

1 Like

Awesome
Cheers @Subhass

The solution is:
Add the EntryMethodParamter in VBA Code like as below
Sub MoveBeginning(mnth as string) and the code should be Range(“C2”).Formula = “=FIND(”“” +mnth+ “”“,B2)”.

Thanks a lot @Palaniyappan , @sunilRdGlobal and @fernando_zuluaga

2 Likes

hi All,

Can any one help me with this

I’ve below VBA code, I want pass my range from data table row value. Am not sure how it will work.

Row value I will get every time example when foreach runs my 1st value will be C2:G2.

Public Sub AutoFitMergedCells(oRange As Range)
Dim tHeight As Integer
Dim iPtr As Integer
Dim oldWidth As Single
Dim oldZZWidth As Single
Dim newWidth As Single
Dim newHeight As Single

With Sheets(“MASTER”)
oldWidth = 0
For iPtr = 1 To oRange.Columns.Count
oldWidth = oldWidth + .Cells(1, oRange.Column + iPtr - 1).ColumnWidth
Next iPtr
oldWidth = .Cells(1, oRange.Column).ColumnWidth + .Cells(1, oRange.Column + 1).ColumnWidth
oRange.MergeCells = False
newWidth = Len(.Cells(oRange.Row, oRange.Column).Value)
oldZZWidth = .Range(“ZZ1”).ColumnWidth
.Range(“ZZ1”) = Left(.Cells(oRange.Row, oRange.Column).Value, newWidth)
.Range(“ZZ1”).WrapText = True
.Columns(“ZZ”).ColumnWidth = oldWidth
.Rows(“1”).EntireRow.AutoFit
newHeight = .Rows(“1”).RowHeight / oRange.Rows.Count
.Rows(CStr(oRange.Row) & “:” & CStr(oRange.Row + oRange.Rows.Count - 1)).RowHeight = newHeight
oRange.MergeCells = True
oRange.WrapText = True
.Range(“ZZ1”).ClearContents
.Range(“ZZ1”).ColumnWidth = oldZZWidth
End With
End Sub

But I got this error every time please advise how to solve this
image