1、以excel2010版本为例,如下图,要将工作表1的语文成绩匹配到工作表2;
2、首先在工作表2的C2单元格输入公式=VLOOKUP(A2,'[新建 Microsoft Excel 工作表.xlsx]Sheet1'!$A:$B,2,0),第一个参数是查找值,第二个是查找范围,第三个参数是查找列数,第四个参数是精确匹配,输完后按enter键则可得出匹配结果;
3、把鼠标放在C2单元格,下拉填充公式,则可成功匹配出工作表2C列的语文成绩了。
excel表格中,匹配关键字可以找出两个表格数据的相同值并进行分析与计算。通常有两种方法:
1 公式法:
比如在sheet1的A列,需要查找sheet2的B列在不在A列里面,那么在Sheet2的C列就可以写如下公式:
=vlookup(B1,sheet1!A:A,1,0)
sheet1的数据:
sheet2的数据与公式
途中#N/A就是没有找到,未匹配。
方法二:通过vba代码来查找并上色:
Sub filter()
Dim s1 As Variant
Dim i, j As Integer
Dim foundRange As Range
Application.ScreenUpdating = False
s1 = Sheet2.Range("B1:B180").Value
For i = 1 To UBound(s1, 1)
Set foundRange = Sheet1.Range("B1:B20357").Find(What:=s1(i, 1), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not foundRange Is Nothing Then
Sheet1.Cells(foundRange.Row, 2).EntireRow.Interior.Color = rgbRed
Else
MsgBox s1(i, 1) & "并未在sheet1中找到", 64
End If
Next i
Application.ScreenUpdating = True
End Sub