Delete entire row from Excel


Below is the excel

i want to delete first row from excel if the excel contains rows eg:2 and 3 rd row as shown in the screenshot.

if excel contains only one row as shown below we should not delete the first row.

Please help me with logic

Thank you

Hi @vinjam_likitha

First use a read range activity to retrieve the datatable from excel
Then can use Filter datatable activity and check if the row contains the words “No items returned” if so, then keep this row, if not, then delete that row
Then write it again to excel



You can read the excel cell A2 using read cell and check the value using a if condition

Str.Equals("No items …")

On the then side add nothing and on else side use delete row activity with specific row and give 2 as the row number



Hope the below steps would help you resolve this

  1. Use a excel application scope and pass the filepath of excel

  2. Inside the scope use a read range activity and get the datatable as dt

  3. Now usually a merged cells can be read with read cell of the first merged cell
    Use a READ CELL activity and mention as “A2” in cell property and get the string output as Strinput

  4. So now use a IF condition like this


If true it goes to then block where we need to remove the cell with that text value as mentioned above and if it fails we can ignore without activity in Else block as we should not remove if it’s having only this record
But before that use a bother if condition in then block
With condition like this

Strinput.ToString.Contains(“your text”)

If this is true it goes to then block where use a DELETE ROW activity but if fails it goes to else block where leave it as it is without any activity

Cheers @vinjam_likitha


In delete row activity


Properties are correct?

1 Like

Yes @vinjam_likitha
Check once with the position
1 means first row and 2 means second row

1st row means headers will get deleted or 1st row data.

Header will get deleted for position 1 @vinjam_likitha

Hi @vinjam_likitha

Try with the below following

  1. Use the Excel Application Scope activity to open the Excel file that contains the row you want to delete. Specify the file path and the name of the sheet that contains the data.

  2. Use the Read Range activity to read the data from the Excel sheet into a DataTable variable.

  3. Use a For Each Row activity to loop through each row in the DataTable. Inside the loop, use an If activity to check if the current row meets the condition that you want to use to delete the row.

Condition : dt.Rows.Count>1

  1. If the condition is true, use the Remove Data Row activity to delete the entire row from the DataTable. To do this, specify the Data Table variable, the current row index, and set the “Shift Positions” property to “True” to ensure that the remaining rows are shifted up to fill the gap.

  2. After the loop has completed, use the Write Range activity to write the updated Data Table back to the Excel file. Specify the file path and sheet name, and set the “Add Headers” property to “True” if the Data Table contains column headers.

  3. Use the “Close Workbook” activity to close the Excel file.


Hi @vinjam_likitha

You can use “IF” Activity and Pass the Condition i.e. DT.RowCount>1 after reading the Data Table. If the Condition gets true use “Remove Data Row” workbook Activity and Pass 0 as Row index. That’s How you will remove the 1st Row.

Hope this will Work,

Thank all for the Solution

1 Like

Glad it got resolved @vinjam_likitha

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