Delete last rows

Hello,
I want to delete last row. (delete row that column Round and Type = blank )

image

Please guide me about it.

Hi @Stef_99

Use the read range workbook activity and store the data in a data table variable and then use REMOVE DATAROW ACTIVITY where for last row mention RowIndex as dt.Rows.Count-1

Regards

Hello @Stef_99 ,

Use the Filter Datatable activity and apply the conditions according to your requirements. This should work.

@Stef_99

Dim rowToRemove = (From row In dataTable.AsEnumerable()
                   Where String.IsNullOrEmpty(row.Field(Of String)("Round")) AndAlso
                         String.IsNullOrEmpty(row.Field(Of String)("Type"))
                   Select row).LastOrDefault()

If rowToRemove IsNot Nothing Then
    dataTable.Rows.Remove(rowToRemove)
End If

Hi @Stef_99

Check the below attached screenshots for better understanding:
image

Regards

1 Like

It error as below.

Use read range activity first to store the data in datatable,
then use remove datarow activity to remove the required column

Row index as data.Rows.Count-1

1 Like

hello @Stef_99 ,

Initially take ’

rowCount = dt.Rows.Count

dt is your datatable

then

dt = dt.AsEnumerable().Take(rowCount - 1).CopyToDataTable()

Regards,
Dheerandra Vishwakarma

1 Like

@Dheerendra_vishwakarma @Shravan_Pintu Is solution by delete row in excel?

Hi @Stef_99

Please check the solution I have provided earlier.

Regards

1 Like

@Stef_99 yes you can do by reading your excel as a datatable…

1 Like

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