Need Help with comparing Datatables

Good Day all,

Currently I am required to get values from 2 different excel sheets,
lets call them Excel A and B.

On A, it is just a column of numbers. I need to match that value on B, if it matches, extract the whole row of data to be inserted on a 3rd excel file.

For now, what I am doing is getting 2 dt and running a for each row to compare the 2 dt.

I know that even cell colours play a part, I am just not sure how to go about doing this.

So far at the for each loop, there is an error message when i try to compare the 2 dt.

“dtVoteNumber.Rows(“VoteNo”).ToString() == dtFullDetails.Rows(“Vote”).ToString()”

My technical skills with coding are limited, will appreciate any direction you guys can give me.

@Lim_Xiu_Qi , check this post: Story line of Join Data Table - #2 by shanmukh_pothamsetty in this you need inner join to your case


1 Like

alright, will study the join function. thank you!!


to get Matched results:
Datatable Out_Matched_Data = In_DataTable1.AsEnumerable().Where(function(row) In_DataTable2.AsEnumerable().Select(function(r) r.Field(Of String)( VoteNo.ToString)).Any(function(x) x = row.Field(Of String)(VoteNo.ToString))).CopyToDataTable()

Try this

1 Like

“dtVoteNumber.Rows(Index).Item(“VoteNo”).ToString() == dtFullDetails.Rows(Index).Item(“Vote”).ToString()”

You made the wrong syntax

1 Like

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