My write range not overwriting existing contents, can anyone diagnose why?

Hello Sweet People,
@loginerror @ziga.hanzic

Am trying to Automate a excel activity where the subject of the mail should get into excel rows. My problem is write range activity doesn’t overwrite existing content when running for the secondtime … How can I make it overwrite existing content, thanks

Main.xaml (8.0 KB)

Hi @u322805,

Can you check below link it might helps you to understand.

Write range overrides and gives the latest file processed data. how to get rid of this overridden thing?

Regards,
Neelima.

@u322805 - i am guessing your problem is that it IS overwriting data, but the 2nd time there is less data, so there are leftovers from the 1st run.

For example, if run1 has 20 rows, then the excel will have 20 rows.

Now with run2 if there are 10 rows, then the excel will still have 20 rows (first 10 rows are data from run2, next 10 rows are leftover data from run1)

If you want to re-use the same excel sheet, then the best practice is to completely remove all existing data in that excel sheet

Hi 1996, thanks for the reply … My problem is it is not overwriting, it is taking new rows everytime … In detail if am running the program for the first time it takes 5 subjects and writes from 2nd row to 6th row … When I run for the 2nd time it writes from 7th row to 11th row, and third time 12th row to 16th row … But I want it to overwrite existing data i.e., For all the runs (Be it 1st or 2nd or nth) it should start writing from 2nd row only
Any solution? , Much appreciated

Dear Dave,
Nope, thanks for the reply … My problem is it is not overwriting, it is taking new rows everytime … In detail if am running the program for the first time it takes 5 subjects and writes from 2nd row to 6th row … When I run for the 2nd time it writes from 7th row to 11th row, and third time 12th row to 16th row … But I want it to overwrite existing data i.e., For all the runs (Be it 1st or 2nd or nth) it should start writing from 2nd row only
Any solution? , Much appreciated

Dear Dave,
I have also used a write cell activity to clear the contents but it’s not working, no idea why
If you can see the file attached earlier in this post, you will know. Thanks

@u322805 I am unsure why you have the write cell activity in there. You also have the range “A2:Z500” listed in write cell activity, but I believe write cell only works for a single cell, not a range of cells like that, so it is only working on A2. I would recommend removing that activity altogether.

The reason why it is working this way is because the very first activity you have is a read range activity. This means that whatever you have in existing in the excel is added to your datatable. Then you get the top 5 emails and add the subject & date received to your datatable so you have your existing data + the new 5 rows and writes it all back to excel.

If you don’t want it to include the old data, then you should not use the read range at the beginning and should instead use a build data table activity to initialize your starting datatable.

Got it Dave Thank you so much, it works

Main.xaml (9.1 KB)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.