Compare column values in different excel sheet and update missing value

In the automation process, we need to compare the Request ID from Sheet2 with the Receipt Number in the Result sheet. For those Request ID values in Sheet2 that are not present in the Result sheet, we need to add a new column to the Result sheet and update it with the missing Request ID and Request Date from Sheet2.

First input sheet

Second input sheet

By using this linq expression got the below request

image

I want to update the request date in the result sheet and the output should be like this,

Kindly help me to achieve the result

Assuming:

  • dtSheet2 is your DataTable from Sheet2.
  • dtResult is your DataTable from the Result sheet.

Dim missingRows = From row2 In dtSheet2.AsEnumerable()
Where Not dtResult.AsEnumerable().
Any(Function(row1) row1.Field(Of String)(“recepit Number”) = row2.Field(Of String)(“Request ID”))
Select dtResult.NewRow() With {
.Item(“Receipt Date”) = “”,
.Item(“recepit Number”) = row2.Field(Of String)(“Request ID”),
.Item(“Request ID”) = “”,
.Item(“Request Date”) = row2.Field(Of String)(“Request Date”)
}

Merge Missing Rows into dtResult

For Each row In missingRows.ToList()
dtResult.Rows.Add(row)
Next

If the “Request Date” column does not yet exist in dtResult, you can add it before the LINQ:

If Not dtResult.Columns.Contains(“Request Date”) Then
dtResult.Columns.Add(“Request Date”, GetType(String))
End If

If you find this as solution then mark it as SOLUTION

Happy Automation

tests.zip (143.3 KB)

Hi @bhavesh.choubey

I have attached the file.Kindly review the main workflow.Gives only request id.need to update request date also.