Here i have 2 columns columnA and columnB having integer values and i wanted the addition result of columnA and columnB in 3rd column i.e. columnC. But i want this in 2 different way.
Q1. Keeps the excel open and writes the result in real time, row by row so you can see the changes.
Q2. Keeps the excel closed,set the column values in the memory DataTable and adds all the tables to the excel file at once in the end.
For q1 we can use VBA to put an formula and filldown it.
Sub filldow()
Range("C2").value = sum(A1:b1)
Range("C2:C" & cells(rows.count,1).end(xlup).row).filldown
End sub
Refer this for how to use vba in UiPath
For q2 follow the below steps,
Read the excel sheet data in the datatable variable name dt.
Add a activity called build datatable(output dt2) and give 3 column name (all are int).
Use write range and give the query as below in datatable property,
(From dtRow in dt.asenumerable
Let a = cint(dtRow(0).tostring)
Let b = cint(dtRow(1).tostring)
Let c = a+ b
Select dt2.rows.add({a,b,c})).copytodatatable
Can you pls show me properly what u have written in assign activity.And where is the addition of two columns u did? And also i wanted to write the result in columnC.
Ok. I have used C# here. The below code is for vb
CurrentRow(2)=Convert.ToInt32(CurrentRow(0))+Convert.ToInt32(CurrentRow(0)).Try this code and let me know whether it works or not.