How to sum up a same positioning cell in excel from different sheets through uipath without using the excel formula

Basically what the question states. I want to add up the same positioning cell in different sheets in excel. For example, in sheet1, the value in cell c2 is 10 and in sheet2, the value in cell c2 is 12 and the total from both cell is 22. I want to do this using UIPath. Please help me. Its due next friday!!!

Hi @owlskull_z ,

Usually, when we request help on the forum - first we try to actually do what we need and attach in the post what we already tried and ask for advice on how to fix what doesn’t work.
We don’t expect somebody else to do the work for us.
Being that it’s your first time posting, my advice is to take a look at the excel activities in Studio and you will find everything you need there. Please try to do it yourself first and if you don’t succeed - take a look at the workflow i attached here: addSameCellFromAllSheets.zip (49.2 KB)

All the best,
Constantin

1 Like

ok thank you very much for the help.

1 Like

hi i was just wondering why does it work when the variables name are not the same?

Hi @owlskull_z ,

The basic logic is as follows:
– first we open our input excel file
– next we read the sheet names into a list of strings, which is a type of collection, so the result will be {“Sheet1”, “Sheet2”, “Sheet3”}
– then we go through all the items of this collection - for this we use the For Each activity (for each item in the previously read sheets list).
– at the first itteration it means that “item” will have value “Sheet1”
–now we use the Read Cell activity which has 2 input parameters:

  1. the sheet name - so it knows from which sheet to read (in our case the value of item - so “Sheet1”)
  2. the cell position - so it knows from which cell to read
    The value that is found in the sheet at that particular cell is saved in variable valueReadFromCell which is the result (otherwise called output parameter). Let’s consider it to be 12 for this explanation.
    – next, we add this value to our sum (the assign activity). Our sum has been initialized with 0 at the start of execution (see Default value in Variables panel), so the operation executed will be 0+12 = 12. Now our sum is 12.
    – because we finished the activities for this value of item, we move to the next value - so item becomes “Sheet2” and perform the activities again. This time, let’s say that valueReadFromCell is 10, so the operation performed will be 12+10 so our sum becomes 22
    – again, we finished all activities for the value of item = Sheet2, so we move to the next value in the list “Sheet3” and we do the activities again.
    – let’s say that valueReadFromCell is 101, so the operation performed will be 22+101 so our sum becomes 123
    – we finished the For each activity, because there are no more values in the initial list of read sheets, so we move to the message box and we display the sum.

You can see this exact behaviour by running the script with “Step into” functionality in the Debug menu. Hope this helps.

Constantin