Compare 2 datatables, write match to next column where they match

Hey everyone,

I have 2 excels (1 is main excel, second is check excel) , what I need is compare these 2 datatables’ “Material” column. On the matching rows I want to write match/no match to “State” column on the main excel.

I want to do it without using loops. I know there is a way to do it but I dont know how :smiley:

I appreciate every bit of help

@jntrk - please search in forum …I have seen exactly similar post(s) before …

Actually I’ve searched but couldnt find the a solution for this.

@jntrk Check if the below posts can help you. If you still need more help, can you address your problem in a bit more detail, maybe with Sample Inputs and the expected output that you need.

Thank you for your links but the problem I face is not on matching the excel I can get them compared and output the matched/non-matched tables seperately.

To example what I need:

MainExcel (dont mind blah blah columns the excel has 9 columns, thats What I meant)

Check Excel

I want to make the matching row as matched on the main excel (without corrupting the excels format, its xlsm-macro enabled doc. so I dont want to break it :slight_smile: )

@supermanPunch any ideas?

@jntrk We can do it using datatable and Linq approach but if you need the format to be not modified we would have to think of an alternate, or can you tell me what kind of format is involved for the file ?

Well there are some macros enabled, and the headers have filter option enabled on them. Linq is the only approach in my mind as well, but I couldnt make it work, I am new to using queries. If we read the excel range with “preserve format” use linq then write with preserved format, thats the only solution I have :slight_smile:

Could u help me wtih the linq?

@jntrk If you provide the sample data with the same format (i.e having macros enabled and other formats), we can try using Linq and give you the result, so that you can check if it is the expected output that you need.

@jntrk Can you check this workflow : (87.8 KB)

I was not able to implement it completely in Linq and Update the excel, as it would lead to disrupting the formats present. But I have used the Material Code from Other Sheet to fetch the Indices of the matching Code from Raw Materials Sheet and then Update the Required Column Value using Write Cell Activity.

However the format of the Number turns to String.

Check if it satisfies your requirement.

It satisfies Thank you very much.

1 Like

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