vlookup函数两张表匹配(EXCEL表中如何利用VLOOKUP将
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 VariantDim i, j As IntegerDim foundRange As RangeApplication.ScreenUpdating = Falses1 = Sheet2.Range("B1:B180").ValueFor i = 1 To UBound(s1, 1)Set foundRange = Sheet1.Range("B1:B20357").Find(What:=s1(i, 1), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRos, SearchDirection:=xlNext)If Not foundRange Is Nothing ThenSheet1.Cells(foundRange.Ro, 2).EntireRo.Interior.Color = rgbRedElseMsgBox s1(i, 1) & "并未在sheet1中找到", 64End IfNext iApplication.ScreenUpdating = TrueEnd Sub