How to check if one column is equal another colum in excel and add a new column

I need to compare ‘ID’ column of MainExcel to ‘ID’ column of UpdatedExcel and find out the mismatched values If different I need to add the informations on a new column at MainExcel

regards,

1 Like

Hey @siteltower

What do you mean by mismatch here please ?

Thanks
#nK

Hi @siteltower ,

Would this be of help?

You can check if the count is greater than 0, if so that means there is a mismatch.

Dt1.AsEnumerable().Select(Function(s) s("ID").ToString.Trim.ToLower).Except(Dt2.AsEnumerable().Select(Function(s) s("ID").ToString.Trim.ToLower)).ToList()

Kind Regards,
Ashwin A.K

1 Like

if there are values that are different from each other (like if has updates)

1 Like

Thank you but it would only work with a new number of rows or columns are added right?

I’m working with the same number of columns for all sheets that only thing that changes is the value inside it

1 Like

Hi @siteltower ,

Correct me if I am wrong, but you want to check if the two columns contain the exact same values right?

that snippet of code collects the Column Values from both tables and retrieves those values from Dt1 which aren’t present in Dt2 i.e., values in Dt1 Except in Dt2.

If its empty, that means there are no values which aren’t present in Dt1.

Kind Regards,
Ashwin A.K

1 Like

Thank you but is not that
The code will check for the length? I need to check if same columns on both tables are different

Hi @siteltower ,

Would you be so kind as to provide us with some sample data, and an example of the operation you wish to perform?

That would put us in a much better position to assist you.

Kind Regards,
Ashwin A.K

1 Like

tranferTableMaster.xlsx (8.1 KB)
transferUpdate.xlsx (8.1 KB)

Everyday I receive the file transferUpdate and I need the rpa to check the infos there and update on the transferTableMaster

Hi @siteltower ,

Thank you for the sample data, now do you want to check if the ID from transferUpdate file exists in transferTableMaster, and update the Status and Issue columns?

Kind Regards,
Ashwin A.K

Yes that is correct :slight_smile:

Hi @siteltower ,

Could you try and see if the logic performs the operation as expected?

(From row In dt_masterData.AsEnumerable()
Let upd = dt_updateData.AsEnumerable().Where(Function(w) w("ID").ToString.Trim.Equals(row("ID").ToString)).ToArray()
Let ra = New Object(){row("ID"),row("Service Type"),row("Assets SN"), upd.First().Item("Status"),upd.First().Item("Issue"),row("Name"),row("Project")}
Select dt_result.Rows.add(ra)).CopyToDataTable()

CheckIfColumnsAreSame.xaml (7.8 KB)

Kind Regards,
Ashwin A.K

1 Like

That is is
Perfect :slight_smile: Thanks a lot

1 Like

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