Delete excel row based on if condition

Hi there! I’m using an excel for each row activity, and I need to delete or ‘ignore’ the rows from the spreadsheet that in the column P, or “Status”, are equals to “Arquivado”. How can I do this? Thanks! :smiley:

  1. Inititalize one counter = 0 before the start of for loop.
  2. In the for loop check the condition and if it matches then use “Remove Data Row”
  3. In the properties , you will find index , pass the counter variable as index.
  4. Increase the counter = counter +1

Just put an If around the Delete Rows activity.

If you want to skip the row, the following works.

If you want to remove rows, the following will work. (9.1 KB)


Why not just use the Delete Rows activity inside the loop?


Can you check the following message? To make sure, it’s better to be used outside ForEachRow loop, I think.


Maybe you can use Filter Data Table activity instead of using For Each Row?

I wouldn’t necessary advise using For Each when you are dealing hundred of thousands of data rows, it has longer processing time.

Ahhhh I hadn’t tried it so I didn’t know that. Thanks!

Basically when deleting a row in a for loop you will miss the index. In short the input datatable cannot both be iterated and modified in the same for loop.

@ton I agree, Filter Datatable is an elegant way of solving this issue.

I tried the first way to ignore it! Lets see if it works! Thank you sm! :smiley:

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