How to sum the data of cells if its upper cell contains specific words

Hi All,

I am new to UiPath and I am having trouble to do the calculation using UiPath. Please refer to the screenshot below, for each product, I want to add up the sales amount which under the colored columns in Data A to create Data B data.

I have studied a while but still, have no clue to do so. Appreciate if you could share your method or sample xaml. Thank you!

@ArthurHK

Hi,

Do you realy need robot to do such calculations ? Isn’t better just create macro in Excel, ofcourse you can run macro using a robot :wink:

Hi @ArthurHK
Based on Datatable select you can get the value

NewDt=Dt.Select("["+Now.ToString+("%d%m%y")+"]<>’’").CopyToDatatable()
assign these values to a row(“ColumnName”)
and then calculate the sum

Thanks
Ashwin S

Hi rado,

Thanks for the reply. As I will receive the excel every day, I want to have the robot to download the it from outlook and perform the calculation.

Btw, I am not familiar to macro ={

Hi Ashwin,

Can you share more about how to calculate the sum? Thanks!

Hi @ArthurHK

Dt=Convert.ToInt32(Dt.AsEnumerable().Sum(Function(row) row(“ColumnName”)))
(or)
Dt=Dt.Compute(“Sum(Column Name()”,“Column Name2”))
Thanks
Ashwin S

You can record a marco just sum cells manually, then you can edit macro to do the same for others cells, then save macro as global ( to access from all excel files ). Then robot can open and run macro.
There are plenty of tutorials how to create/edit macros in the Excel.

@AshwinS2 method is good but still i think this is over engeneering.