Remove specific values under a column and then remove the whole row on the same "level"

I have the columns “A” all the way to “L”, I have values that look something like this under column “G”

11112233-0000

I need to remove all the values with 0000 in the end under column G
But i also want that the entire row for the level is removed. So when i remove the cell with 0000 in the end I want that all the rows on the same “level” from Column “A” to “L” also gets deleted/removed.

Is this possible?

Example: row 50, 129, 2999 contains “11112233-0000” under a cell in column “G”. Because the cell contains “0000” i now want to remove the rows 50, 129 and 2999.

Assuming your datatable name is dt use below linq.

(from dr as datarow in dt where not dr.item("columnNameG").ToString.EndsWith("0000") select dr).CopyToDataTable

Thanks, but how exactly should i set it up. How do i use this exactly.

@atomic

  1. Read your excel file in a datatable and output as dt.

  2. Use assign.

dt=(from dr as datarow in dt where not dr.item("columnNameG").ToString.EndsWith("0000") select dr).CopyToDataTable

Make sure you change your column name.

  1. use write range, to write this data back to excel.
1 Like

Thank you so much, works great :smiley:

1 Like

@atomic
first stop is to check if essential activity is working for the case:
Filter Data Table
grafik

if its not working then we do work with:
DataTable.Select(…
Or LINQ

this other Topic looks like a Duplicate:

Please avoid and close as well

Does that activity remove all the rows on the same level aswell if the filter meets the condition?

I removed the duplicate :slight_smile:

@atomic
best thing for exploration is trying.
I didnt get your question as same level, duplicates are unclear to me. But as it is flagged as solved, so it is fine. Otherwise we are here for your open questions

1 Like

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