Help in Excel column data matching

Hi All,
i have a scenario that i need to look company name from SHEET1 and look that Company Name in SHEET2 and i want to write those in OUTPUT sheet.
My code is working fine but there is an issue some company names having additional special characters because of that I’m unable to match it. i can’t use contains because if another company also contains similar kind off name it will take that.
I want to work with special characters how can i.
I’m attaching my code below for reference.

CompanyNameMatch.zip (11.3 KB)

Hi,

Can you try the following expression?

dt_Test =  Sheet2_DT.AsEnumerable.Where(Function(x) System.Text.RegularExpressions.Regex.Replace(x("Company Name").ToString,"[^\w\s]","").Trim.Equals(System.Text.RegularExpressions.Regex.Replace(row("Company").ToString,"[^\w\s]","").Trim)).ToList()

Regards,

Hi @Yoichi thanks for the code but when i run my code it is not printing all matching rows. It is skipping 1 record - **Universal Logistics Holdings Inc.
**
Did i made any mistake in code.

Hi,

Can you share your expected output?

Regards,

@Yoichi If my Sheet1 Company Name matches with Sheet2 Company Name. I need to pick all the matching records from Sheet2 and write in Output sheet.

Company Names Match.xlsx (10.4 KB)

Hi,

In Sheet1, there is duplicated rows as the following.

image

If you want to handle them once, it’s necessary to get rid of duplicated row in advance.

 Sheet1_DT = Sheet1_DT.DefaultView.ToTable(True,{"Company"})

Regards,

Hi @Yoichi Still i’m not getting all records. Even it is not writing all records of **Universal Logistics Holdings Inc.
**

image

Can you check the following sample?
(Workbook activities are used because excel is not installed in my current environment)

CompanyNameMatchV2.zip (10.7 KB)

1 Like

This is working perfectly. Thank you @Yoichi

1 Like

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