根据地图replace列中的值

我在Excel工作表中有两列A和B,类似于以下内容:

AB 1 1 2 2 3 4 4 5 5 6 6 7 7 8 8 10 9 11 10 12 11 13 12 15 13 16 14 17 15 18 

现在,在另一张表中,我有一列B值,我想将它们映射到相应的A值。 通过“映射”它们,我的意思是用第一个表格中与其相邻的A值replaceB值。 我该怎么做呢?

选项1)

在sheet2的列C中,你需要你的结果,并且让B和B的数据在D列中混合起来。

 =INDEX(SHEET1!$A$1:$A$15,MATCH(D2,SHEET1!$B$1:$B$15,0)) 

选项2)

相同的设置,但让我们使用LOOKUPfunction

 =LOOKUP(D2,SHEET1!$B$1:$B$15,SHEET1!$A$1:$A$15) 

使用Sheet1如:

在这里输入图像说明

Sheet2一样:

在这里输入图像说明

运行这个简短的macros:

 Sub Translate() Dim B As Range, RangeToFix As Range, r As Range Dim fnd As Range Set B = Sheets("Sheet1").Range("B1:B15") Set RangeToFix = Sheets("Sheet2").Range("B1:B11") For Each r In RangeToFix Set fnd = B.Find(What:=r.Value, After:=B(1)) If fnd Is Nothing Then r.Offset(0, 1).Value = "not found" Else r.Value = fnd.Offset(0, -1).Value End If Next r End Sub 

将在Sheet2中生成这个:

在这里输入图像说明

这就是“翻译”的原地。