Delete data row from data table



I am having a excel in format

Now I want to delete all the row where Status=“PV”.

Please suggest a solution. I want to perform this action using one database table only.

Delete the row if column has "0"
Hot key down arrow

Hey @mgangrade7

To delete rows from datatable, you could use the logic like this:

  1. Use the select function on the datatable to filter the rows that match your condition and this will return an array of Datarows.
  2. Then use a for each loop and remove each row from the Array of Datarows using datatable.Rows.Remove(row);

For Your Reference find the attached sample solution: (7.7 KB)


Delete datarow in datatable
Remove empty row in the excel

@aksh1yadav: Why not using RemoveDataRow instead of InvokeMethod?


SAMPLE1.xlsx (8.6 KB)

@aksh1yadav How to remove if complete row is blank row.For Example i am attaching xlsx file .In this xlsx file 4th row is completly blank row. how to remove this row ?


Just Use the If condition to check those required columns are blank or not then if they are then use Remove data row activity .


@aksh1yadav In your attached in assign field you are assiging data.Select("[Status]=‘PV’").where i need to use if condition,can you please share the xaml file for this ?


this statement returning the rows which are having status ‘PV’. so you have to modify it something like this for your requirement

DataTable.Select("[COLUMN 1]=’’ OR [COLUMN 2]=’’")

and if null values you have then you can use like this:

DataTable.Select("[COLUMN NAME] is null");

and then you can easily inside for each loop ,can use Remove data row activity.


To select Column with null values

@aksh1yadav when i am providing properties for Remove data row Activity, i am getting an error and not able to resovle this one.For reference i am attaching my xaml file.Can you please help me regarding this issue so that i can delete my blank row from xls (7.9 KB)



Use “Item” in row field of remove data row activity.



DeleteRow.xaml (13.0 KB)

Try this.



Suppose if i want to delete a row in which a column contains a particular string…How to do that…?


Hey @Sam

You have yo use similar with your column name and string then it will return an array of DataRow. then you can use Foreach loop and inside Remove data row activity pass that filtered row item.



ok i got that.
but Suppose in a datatable i want to remove those rows in which a column contains a particular word “Forward”.
for example- my string is “Forward: UiPath v/s blueprism”. I want to remove all those rows which contains this word “Forword”. ?


Datatable.Select(“ColName LIKE ‘Forward:’”) to filter those rows.



Hi rahul like here you have put PV but i need to delete row which are not equal to a string variable how should i delete row then as variable value keep on changing


Hi aksh1yadav like here you have put PV but i need to delete row which are not equal to a string variable how should i delete row then as variable value keep on changing


My column name is ENODEB and my variable is Current_SiteID. so in a data datable if row is not equal current_siteid ,then delete row


Hi there @1vivek12.

You can do the following:

dtMyDataTable = dtMyDataTable.AsEnumerable.Where(Function (x) x.Item("ENODEB").ToString.Trim.ToLower.Equals(current_siteid.Trim.ToLower) = True).CopyToDataTable

This will return a DataTable where all rows meet your criteria (‘ENODEB’ column = current_siteid).



Thanks a lot Josh worked like need to delete row now.Thanks! and will help with other things as well.


Hey @Mr_JDavey i need to remove duplicate row based on rows in column Sector_ID. can you help with that too!