How to match the two columns value of one sheet with value of another sheet and if both value match then get third column value

I want to match two columns value of one sheet with another sheet columns value if bot values are matched then will get the third column value.
How to get this done. Please help me.

Could you specify the columns you want and could you provide the sheets for a more detailed answer

@shailesh1920

  1. Excel Application Scope (Provide the file path)

    1. Read Range (Sheet1) - Output: dtSheet1

Assign:CurrentRow(“YourColumn”).ToString=YourSheet1match

  1. Read Range (Sheet2) - Output: dtSheet2

CurrentRow(“YourColumn”).ToString=YourSheet2match

if condition:YourSheet1match.Trim=YourSheet2match.Trim
- Assign activity: matchedValue = row[“Column C (Sheet1)”].ToString (Store the value in a variable or use it as required)

Both sheet having Same column name only one column name is different.
Basis of “Material Text” and “Net Price”, I want the activity number if this both column values are matched.

Please help with LINQ query.

Hey @shailesh1920 , Try this and let me know if any error arrises

(From row1 in dt1.AsEnumerable
Join row2 in dt2.AsEnumerable On row1("Material Text") Equals row2("Material Text") and row1("Net Price") Equals row2("Net Price")
Select dtOutput.Rows.Add(row1("Material Text"),row1("Net Price"),row1(3))).CopyToDataTable

Note: - dtOutput should be initialized either by using dt1.Clone or Build datatable

Both sheet having Same column name only one column name is different.
Basis of “Material Text” and “Net Price”, I want the “activity number” Column value if this both columns values are matched.

If you want only the column activity number, then

(From row1 in dt1.AsEnumerable
Join row2 in dt2.AsEnumerable On row1("Material Text") Equals row2("Material Text") and row1("Net Price") Equals row2("Net Price")
Select row1("activity number")).ToArray

The above query will first join both tables on Material Text and Net Price and then select the activity number from those fields which are matched and joined. Then the resultant value is converted to an array

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