|
- Sub 筛选编号()
- Dim i%, j%, lastrow1%, lastrow2%, arr1(), arr2()
- lastrow2 = Sheets(2).Range("B10000").End(3).Row
- lastrow1 = Sheets(1).Range("B10000").End(3).Row
- arr1 = Sheets(1).Range("A2:B" & lastrow1).Value
- Sheets(2).Range("C2:C" & lastrow2).ClearContents
- arr2 = Sheets(2).Range("B2:C" & lastrow2).Value
- For i = 1 To UBound(arr2)
- For j = 1 To UBound(arr1)
- If arr2(i, 1) = arr1(j, 1) Then
- If arr2(i, 2) = "" Then
- arr2(i, 2) = arr1(j, 2)
- Else
- arr2(i, 2) = arr2(i, 2) & "、" & arr1(j, 2)
- End If
- End If
- Next j
- Next i
- Sheets(2).Range("B2:C" & lastrow2) = arr2
- End Sub
复制代码 另外说明一下,你有几个姓名前后有错别字,有的有空格,导致查询不到(显示空白),你修改两边名字统一,就可以得到结果
|
|