If cell does not contain, then delete row?


Sorry to keep posting but im really struggling with this one, spent all day trying to work it out :frowning:

I’m trying to check a column called “ate %” in a datatable.

the column has a % in each row except one is “TEST”. I want to remove the row with “TEST” as that would be an error.

Heres how ive tried :

For each for in DT
Get row item = row / “ate %”-> export as “getrow”
IF getrow.contains("%")
then =
Else = Delete row

However delete row doesn’t work, I believe its because it doesn’t want to delete the table i am currently for each’ing through.


delete row won’t work in a for each row cycle.

I encontred this problem as well, instead of delete row, assing the index position to a collection, then, in another cycle, loop trought each item and delete them.

But, I’m sure there are another way, let the “pros” come here and solve this.


any chance you have that sequence still? i wouldn’t know how to do that


Atos Processuais Executivos.xaml (18.1 KB)


Thank you !

For the most part I understand what is happening, but

Assign countdata = countdata +1

what is this doing? its creating a varible of itself with +1 ?


"Tratar lista actos"

here i loop trought the datatable to see if the string “Data” appears , for each row increment 1 in the variable “countDataCabecalho”, this way i can add the position of the row in the collection.

“row(0).ToString.Contains(“Data”) and countDataCabecalho>1”
i did this because i want to delete all row with the string “Data” except the first one.

In the “Add to collection” i subtract 1 because the table start with 0,1,2…

For each

keep in mind when the first record is deleted the others need to drop a position.
i used the variable “controloItem” to track if is the first remove row or not


practice example.zip (67.2 KB)

I don’t really understand what I’m doing wrong, after testing i either get :

a blank sheet with only the headers
all the %'s removed
nothing changed.

Im trying to make it say
“if there is a % in the “%through contract” column then leave it”
“If there is no % then delete the entire row”

there is a row that i just put “dave” into every column, this would be a bad input so i would like uipath to remove it so i can continue working with the DB


I managed to finally get this working by using a try, “if contains %” assigning the exceptions to to a super high number that would never be achieved, then using a if to filter out the numbers to a report and delete the rows.