Write variable to new sheet only prints last row. Need all rows

Hi there, I am trying to do billing reconciliation in an excel sheet.
The sheet contains of rows of inventory items that were purchased, where the rows are grouped by unique IDs called CIcode(as each CIcode represents a bill that contains several line items of inventory).

(Completed) 1. Sum up the price of all inventory items under each unique ID. I have completed this and the variable that contains the total sum of inventory items under each CIcode is called CIGroupSum.

(Unable to complete) 2. In a new sheet, print the summarised CIGroupSum.
It should print

CI Code, Total Amount
CICode, CIGroupSum

What I have tried
Creating a new datatable called VlookupComplete, where
Assign CurrentRow(“Total Amount”) = CIGroupSum
Write Range to “Sheet2”, “A1”, “VlookupComplete”

I have tried writing cell and writing range, and both instances it prints all the rows of the last CIcode and not the CIGroupSum.

Could someone assist me please? Please let me know if you need more information. Thank you!


Hi @cookiedough

Drag your write range outside the for each and try again once


Hi! I tried dragging it outside but Sheet2 now shows as blank.
I think a step that I’m missing is adding CIGroupSum to my datatable VlookupComplete.
May I know how do I do this?

Hi @cookiedough

Welcome to UiPath community

You can use Path exist activity and use Flow decision or If activity

In then You can use Append Range activity

Else You can use Write Range activity