I have two datatable and i need to get data from 1st datatable and update to second datatable.
For Each r As datarow In dt_Ergo_Mort.AsEnumerable
If dt_Matched_Ergo_Mort.AsEnumerable.Any(Function(a) (a(“CERTIFICATE_NO ANALYTICS”).ToString).trim.equals(Decimal.Parse(r.Item(“INSU_POLICY_NO”).ToString.Trim,System.Globalization.NumberStyles.Any).ToString)) Then
r(“Quote”)=a(“Policy_No Analytics”)
End If
Next
Try the below approach:
For Each Row r in dt_Ergo_Mort:
matchRow = (From a In dt_Matched_Ergo_Mort.AsEnumerable() Where a("CERTIFICATE_NO ANALYTICS").ToString().Trim() = Decimal.Parse(r("INSU_POLICY_NO").ToString().Trim(), System.Globalization.NumberStyles.Any).ToString() Select a).FirstOrDefault()
If matchRow IsNot Nothing
r("Quote") = matchedRow("Policy_No Analytics")
this is my first datatable
this is my second datatable
A column is common in both sheets and i need take B,C,D columns and put in second datatable columns:- B=AR,C=Av and D will go in AW
Hi @nishant.pandey ,
if possible can you share your excel files and will prepare code for you
You can use vLookup, it will compare rows based on the common column in both and you can fill the desired columns based on any condition.