|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub lqxs()
- Dim Arr, i&, Brr, aa, j&, x$, Myr&
- Dim d, k, t
- Set d = CreateObject("Scripting.Dictionary")
- Sheets("工作表2").Activate
- With Sheets(6)
- Myr = .Cells(.Rows.Count, 12).End(xlUp).Row
- Arr = .Range("a1:p" & Myr)
- End With
- For i = 4 To UBound(Arr) Step 5
- If Not IsError(Arr(i, 5)) Then '& "|" & Arr(i, 6) & "|" & Arr(i, 7) & "|" & Arr(i, 8)
- x = Arr(i, 5) & "|" & Arr(i, 6) & "|" & Arr(i, 7) & "|" & Arr(i, 8)
- d(x) = d(x) & i & ","
- End If
- Next
- Brr = [a1].CurrentRegion
- For i = 2 To UBound(Brr) Step 5
- x = Brr(i, 1) & "|" & Brr(i, 2) & "|" & Brr(i, 3) & "|" & Brr(i, 4)
- If d.exists(x) Then
- t = d(x)
- t = Left(t, Len(t) - 1)
- If InStr(t, ",") Then
- aa = Split(t, ",")
- For j = 0 To UBound(aa)
- Cells(i, 9 + j) = Arr(aa(j), 2)
- Next
- Else
- Cells(i, 9) = Arr(t, 2)
- End If
- End If
- Next
- End Sub
复制代码 |
|