如何在Excel中将几乎相同名称的国家/地区配对?

时间:2017-11-23 13:30:02

标签: excel excel-formula

我需要帮助如何配对一些不同的国家名称。问题是我有两个来自不同来源的数据集。在国家/地区的第一个工作表名称中,基于ISO名称和快捷方式,但在第二个工作表名称中不基于ISO名称。

Sheet 1中: enter image description here

Sheet 2中: enter image description here

我尝试使用VLOOKUP函数将官方iso名称与Sheet2中的名称配对,但美国的结果是英国

您是否有任何想法如何避免更换问题名称?

谢谢!

2 个答案:

答案 0 :(得分:0)

我使用映射表来执行此操作,您将sheet1国家/地区映射到sheet2国家/地区,然后您的查找将有一个嵌套的vlookup来获取sheet2中的相应国家/地区

=vlookup(vlookup(sheet1country,yourmappingtable,2,0),sheet2data,yourcolumn,0)

答案 1 :(得分:0)

我有一个近似解决方案,可以解决VBA中表的主要部分,如下所示:

enter image description here

我的代码正在检查它是否可以在第二张工作表中找到该字符串,然后在公制3下面的工作表1中输入相应的结果。 所以在A2中它尝试:
1美利坚合众国 2美利坚合众国 3美国的Ameri
...
13美国(这将是匹配)
问题是,如果你有一个像“英国”这样的国家,在“U.K”等其他名单中有所不同,那么给出的结果将是美利坚合众国。

然而,它需要一些手工工作。

var usrMrid = {name: "mrid"};
var usrXYZZ = {name: "xyzz"};

var comm = {};

comm[usrMrid.name] = "ONE";
comm[usrXYZZ.name] = "TWO";

console.log(comm);// this will print your object correctly.
console.log(comm[usrMrid.name]);// this will print ONE
console.log(comm["mrid"]);// this will also print ONE
console.log(comm["xyzz"]); // This will print TWO
console.log(comm[usrXYZZ.name]); // This will print TWO