Linq Filter Datatable with for each Loop

Hello all,

I have a datatable that has several identical values in the first column and the details in the second column.
My goal is to group/filter all the same values in column 1 and then for each get me the values from column 2. The whole thing works with the following linq command I found, however my problem is that I want to add values in column 3 for the single value in column 2.

List = (From d In in_DT_From_CSV.AsEnumerable
Where System.Text.RegularExpressions.Regex.IsMatch(d(“Column2”).ToString,“\b70\d{10}\b”)
Where d(“Column3”).ToString=“”
Group d By k=d(“Column1”).toString.Trim Into grp=Group
Select g=grp.CopyToDataTable).ToList

List.Item(int_Column1).Rows(int_Row)(“Column3”) = “new Value”.

Write range does not write values

Hi @NHoe

Can you share the sample input and output file?

Filter (63.3 KB)

Hi @NHoe ,

This maybe due to the Datatable that you are using to write back to Excel sheet.

You need to use Filtered_DT.Item(int_Column1), since this datatable is being updated and not the DT_Filter.