How can I perfom a write range every 100 rows

Hi

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

Hi @4751203118d5c62d58b6be22a

You can give cell address in write range as A101,A201 etc it will start writing from that cell.

Or

You can use append range activity for appending the datatable to excel.

Thanks

2 Likes

Draft code . You have to hammer it into shape

MasterCtr = 2.
/* Assuming you start writing at Cell A2 */

For each row
LocalCtr =0
/* 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 */
MasterCtr=MasterCtr+LocalCtr
LocalCtr=100
End if
Next

1 Like

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 .

1 Like

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 :scream:

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:

  1. Reads the 100 GUIDs in Sheet 1 into an input DataTable (this will be replaced by your actual input data)
  2. Loops through the data table
  3. performs fake work by reversing the GUID and converting it to upper case (this will need to be replaced with your actual work)
  4. Adds the result to an output data table
  5. 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
  6. The first time, Write Range is used to include the headers in the output
  7. On subsequent iterations, Append Range is used as headers are not to be appended
  8. 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)