Looping Invoke Code

RPA.xlsx (17.5 KB)

From “Sheet 1” to “Final” sheet with the help of looping in invoke code in a Simple Method ( using For Each and IF Statements)

What i am doing wrong Please tell me while seeing my ScreenShots


as mentioned in the validation message: in line 7,8 you are trying to multiply a string with a number, which is not working.

We would recommend crosschecking or elaborate here more on what you are trying in detail.

The problem is your code:

row("SIGN") = "Amount"*(-1)

You are trying to multiply string with -1.
That why exception is mentioning “cant convert string to double”

but how i loop this in invoke code i didn’t get that
As you see the Excel File above

we do not get your question. Maybe you can reformulate

we also asked for:

but cannot derive a feedback from your answer

When it is about to multiply an amout value by number then we would recommend to first convert the column vlaue to a number (CDbl, Convert.ToXX Function…)

It also looks like the usage of the invoke code is creating a black box for you. So maybe better you will modelled it with essential activities (e.g. for each row, assing) step by step

RPA.xlsx (17.5 KB)

In the Invoke code i need short code
using For Each and IF Condition onlu

Sample.xaml (11.0 KB)

I Have to Write this INVOKE CODE in Short ( LOOPING WAY )


First of all if you want to loop only…then why not use for each row in datatable directly… Invoke code makes no sense


main final.xaml (13.8 KB)

Done but i need in Invoke Code


I did not understand your exact requirement…

But one thing i can see is in your code youare using

Row(“column”) = “anothercolumnname”

The meaning of above is youa re assigning a constant string anothercolumnname to the value of column …that is. Say column A row 1 contains 2 as of now and when you runt he bot the value changes to anothercolumnname

So basically if you want to assign value then try liek below

Row(“column”) = cdbl(row(“anothercolumnname”).ToString)

This if you want to assign a number from one column to another…cdbl is to convert string to number…if you want to assign string itslef then remove cdbl

And for difference cdbl(row(“column1”).Tostring) - cdbl(row(“column2”).Tostring)

I hope with these insights you will be able to modify the current code and work on your conditions


It’s throughing an exception in invoke code


Please use like this

Row(“column”) = If(IsNumeric(row(“anothercolumnname”).ToString.Trim),cdbl(row(“anothercolumnname”).ToString.Trim),0)

I assume row(“Column”) is of type double else after last bracket include a .ToString


it’s through an error
Value can’t be Null


Please replace inverted comma in your code again i guess you copy pasted…

And did you pass the datatble in thw ain argumnet? Or just created an in argument qnd left it?


not copied
if i am removing that then error is occuring that value is not defined


I am not saying to remove.I am asking you to replace them in code…we can clearly see the difference in the inverted comma

You can see a read error mark as well


that is not the issue here


Everytime you give a new comment your code is changing a lot…please have one complete question…with propwr details on what you need …so that we dont waste time on understanding what issuw it is…


someone suggested me that but still getting error
objective is still same

Whenever you are doging var1.ToString or any method you have make sure that some value is present in var1 . It no value is present in var1 the there nothing convert to ToString that why Object reference error is coming.
Add a condition to to check if the data is present or not