- Sub lqxs()
- Dim Arr, i&, Brr
- Dim d, k, t, aa, j&, n&
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Sheet2.Activate
- [a2:c50000].ClearContents
- Arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- d(Arr(i, 1)) = d(Arr(i, 1)) & i & ","
- Next
- Brr = Sheet3.[a1].CurrentRegion: n = 1
- For i = 1 To UBound(Brr)
- If d.exists(Brr(i, 1)) Then
- t = d(Brr(i, 1))
- t = Left(t, Len(t) - 1)
- If InStr(t, ",") Then
- aa = Split(t, ",")
- For j = 0 To UBound(aa)
- n = n + 1
- Cells(n, 1).Resize(1, 3) = Application.Index(Arr, aa(j), 0)
- Next
- Else
- n = n + 1
- Cells(n, 1).Resize(1, 3) = Application.Index(Arr, t, 0)
- End If
- End If
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |