How can I perform a write range every 100 rows instead of at the very end of my process ?
My for each row has too many rows to complete and sometime the bot fail and since my write range activity is at the very end I lose everything I want to avoid that by doing a write range every 100 rows
You can give cell address in write range as A101,A201 etc it will start writing from that cell.
You can use append range activity for appending the datatable to excel.
Draft code . You have to hammer it into shape
MasterCtr = 2.
/* Assuming you start writing at Cell A2 */
For each row
/* Do your work here /
LocalCtr = LocalCtr + 1
If LocalCtr = 100 then
WritePos = “A”+(MasterCtr)
/ first time this would be A2 /
/ next time A102, then A202,etc /
WriteRange your stuff
/ Save next write position */
thank mate but I can’t implement that myself I dont have the skills
Can I share my bot to you ?
Oh sorry I wish I was a bit more clearer. The code was just a representation. It needs to be built in UiPath .
Yes, you can share the project here. I’m on my phone right now and will be able to get to it sometime tomorrow .
bot.xaml (68.4 KB)
Here is it thank you very much !
I am open to better suggestions . I just want to write in the sheet along the way to not lose everything at the end because the bot fails …
I tried to place the write rang within the ‘‘for each row’’ loop (because I dont know better) and it works but when I do that I multiply the processing time by 5
First impression. I am not sure why you need to use an Attach Window inside of an Open Browser.
The Sequence already has several levels of nesting after which the For Each commences.
I don’t have all the supporting material that is used by your robot to perform its function. I will try to send you something generic.
Here is a generic sequence and a data workbook attached.
You set the value of X and the sequence will append the data every X rows to the output.
The Fake work done in this sequence is as follows:
- Reads the 100 GUIDs in Sheet 1 into an input DataTable (this will be replaced by your actual input data)
- Loops through the data table
- performs fake work by reversing the GUID and converting it to upper case (this will need to be replaced with your actual work)
- Adds the result to an output data table
- When the output data builds up to X rows (in this case set to 10, you can change it to see different results), the data is written to Sheet2 of the excel
- The first time, Write Range is used to include the headers in the output
- On subsequent iterations, Append Range is used as headers are not to be appended
- This process repeats within the For Each for every X Rows
You can see the output in the workbook attached and the console will look something like this:
Sample_GUID_Data.xlsx (17.5 KB)
Seq_WriteRange_Every_X_Rows.xaml (19.5 KB)