|
本帖最后由 naolew 于 2017-8-14 21:09 编辑
根据你的要求,用数组结合字典,基本达到目的,请参考!- Sub 查询匹配()
- Dim Arr, i&, Myr&, Brr
- Dim d
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Sheets("整理数据").Activate
- Arr = Sheets("投保名单").[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- d(Arr(i, 3)) = i
- Next
- Myr = Cells(Rows.Count, 1).End(xlUp).Row
- Brr = Range("b1:b" & Myr)
- For i = 2 To UBound(Brr)
- If d.exists(Brr(i, 1)) Then
- Cells(i, 3) = Arr(d(Brr(i, 1)), 2)
- Cells(i, 4) = Arr(d(Brr(i, 1)), 4)
- Cells(i, 5) = Arr(d(Brr(i, 1)), 5)
- Cells(i, 6) = Arr(d(Brr(i, 1)), 6)
- Cells(i, 7) = Arr(d(Brr(i, 1)), 7)
-
- Else
- Cells(i, 4) = "没有参保数据"
- End If
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|