I want a Linq Query to Compare two excel sheet

I want to compare two sheets and take the materials from the PEN sheet and see if it matches the product code on the SKU sheet and find matches
Now if it is a match then take the SKU group and brand in the SKU sheet and then go to the PEN sheet and paste it and if there is no matches then write N/A in the cells

@Melbin_Antu1

you can use the below in the invoke code where dt1 is where you need to update and dt2 is the table from which matches are checked…dt1 send as in/out and dt2 send as in argument

dt1.AsEnumerable.ToList.ForEach(sub(r) r("SKU") = If(dt2.AsEnuemrable.Any(function(x) x("Product Code").ToString.Equals(r("Product Code").ToString),dt2.AsEnuemrable.Where(function(x) x("Product Code").ToString.Equals(r("Product Code").ToString)(0)("SKU"),"NA"))

cheers

Hello @Melbin_Antu1

Assign activity:
dtResult = (From penRow In dtPEN.AsEnumerable()
Let material = penRow.Field(Of String)(“Material”)
Let matchingSKU = dtSKU.AsEnumerable().FirstOrDefault(Function(skuRow) skuRow.Field(Of String)(“Product Code”) = material)
Let skuGroup = If(matchingSKU IsNot Nothing, matchingSKU.Field(Of String)(“SKU Group”), “N/A”)
Let brand = If(matchingSKU IsNot Nothing, matchingSKU.Field(Of String)(“Brand”), “N/A”)
Select dtResult.Rows.Add(material, skuGroup, brand)).CopyToDataTable

Thanks & Cheers!!!