Deleting a row in an Excel table

HI, I need some help.
How can i delete the last empty row that is being read?

Error looks different

May i know what exactly is the requirement and need of deleting the last empty row?

For deleting - you can refer below code snippet

Hi @dvojinovic

The error is something else, but if it is being caused by the last row and you wish to delete it, then use the following code:

dt_Data = dt_Data.Rows.RemoveAt(dt_Data.Rows.Count - 1)

Hi @dvojinovic

First use If activity -Check for Empty Last Row

dt.Rows(dt.Rows.Count - 1).ItemArray.All(Function(x) String.IsNullOrWhiteSpace(x.ToString()))

Then Remove Data Row (Inside If Block)
Row Index: dt.Rows.Count - 1

@dvojinovic,

If data cleaning is the aim here, you can use this LINQ to get only the non empty rows.

dt = dt.AsEnumerable().Where(Function(row) Not String.IsNullOrEmpty(row("ColumnName").ToString())).CopyToDataTable()