How to delete specific rows in excel data table which are not satisfying a condition using a LAMBDA expressions (LINQ)

Can anyone suggest the particular expression to be used for satisfying the question

Use where operator negate your condition and at the end use copytodatatable. It’s let your get new datatable without unnecessary rows. Than you can write them back to excel.

1 Like

Can you share me the syntax as i am new to the platform ?

I’m not sure it would be helpful to you. If you familiar with LINQ in C# than you should just find c# to converter and use it first week. If you’re not than my example will be useless.
I can give you some advice like use invoke code activity for complex linq expressions because it more reliable and better maintainable than simple assign activity.
Because i’m writing this from phone, just googled for you some example:

Dim filteredTable As DataTable = (From r In dt.AsEnumerable()
Where r.Field(Of Int32)(“id”) = 1
Select r).CopyToDataTable()

1 Like