简体   繁体   English

比较Excel中的两个文本字符串以查找它们是否匹配

[英]comparing two text strings in excel to find if they match

I have derived a file using two different methods; 我使用两种不同的方法派生了文件; FoxPro and SQL. FoxPro和SQL。 Because I am most familiar with it, I decided to compare the two end results in Excel to see if they are identical. 因为我最熟悉它,所以我决定在Excel中比较两个最终结果,以查看它们是否相同。 79,954 rows so needless to say, not going to do this line by line. 79,954行是如此不用说,不会逐行执行此操作。 First, I want to see if the company names are the same. 首先,我想看看公司名称是否相同。 I create a new tab and put the company name columns from each next to each other. 我创建了一个新标签,并将公司名称列彼此相邻。 From there, The first method that I used is 从那里开始,我使用的第一种方法是

 =exact (B2,C2)

It returns a false value when I can see with my eyes is not true. 当我用眼睛看不到时,它返回一个假值。 Next I use a very simple IF statement, 接下来,我使用一个非常简单的IF语句,

 =if(b2=c2,0,1)

It returns a value of 1. 它返回值为1。

Is there a better method of doing this? 有更好的方法吗?

EXACT is case sensitive so you need to be sure you don't have any up/low letter mismatch. EXACT区分大小写,因此您需要确保没有任何上/下字母不匹配的情况。

You can also use equal which is NOT case sensitive: 您还可以使用不区分大小写的equal:

=B2=C2

This formula will return TRUE or FALSE. 此公式将返回TRUE或FALSE。

If it's still not working perhaps you have some spaces or other hidden characters. 如果仍然无法正常工作,则可能您有一些空格或其他隐藏字符。 A solution would be to check if B2 includes C2 and opposite. 一种解决方案是检查B2是否包含C2和相反的内容。

=exact (B2,C2)确实有效,但是您可能在某些数据的末尾有一个空格,该数据将返回false而不是true,因为它比较2并发现“ Test”不等于“ Test”,因为那里的空间。

In addition to hakela's answer, you could TRIM them first: 除了hakela的答案外,您可以先对它们进行修剪:

=(TRIM(B2)=TRIM(C2)) =(TRIM(B2)= TRIM(C2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM