Write variable into Excel many times

Hello all,
Every time the run scenario will get code DFR write into D column Excel.

First time write at D2. How can write next time at D3, D4… Thank you

Hello @anh.nguyen
If you are using the While loop or any loop add the varibale index to output for that and provide the 2 as dynamically as β€œD”+(indevariable+2).tostring

or else make a variable which will increment after the completion or at starting

If you are in loop then you can use counter property of For each
BUT I would recommend you to read the excel data into datatable then make changes in datatable and write it back to excel. Working on datatable is significantly faster then write cell activity.

I don’t run the scenario continuously.
Ex: today run 1time, write code DFR into D2.
Tomorrow run 1time, it will overwrite into D2.
How it can write into D3?

Well in this scenario, it will be better if you

  1. Read your excel into datatable
  2. Use Add DataRow activity with required data
  3. Use Write range activity to write the updated data in to excel file.
1 Like

@anh.nguyen
First read the datatable and add datarow to the datatable and the write range again to same excel. or if you want to write directly on excel then

get the last datarow
image
USING modern actiivity or if you only want to use classic then read table get the row count add one in that and go with your flow. providing that count to the cell as β€œD”+Datatable.RowCount+2

1 Like