|
楼主 |
发表于 2018-10-11 09:12
|
显示全部楼层
本帖最后由 wspop 于 2018-10-11 11:42 编辑
各位大神,请看附件图片,有错误。可能是我没有看清楚代码
!请帮忙修改一下
Sub lqxs()
Dim Arr, i&, x$, y$, kk, tt, aa, j&, ii&
Dim d, k, t
Set d = CreateObject("Scripting.Dictionary")
Sheet1.Activate
Cells .Interior .ColorIndex = xlNone
Arr = [al].CurrentRegion
For i = 2 To UBound(Arr)
x = Arr(i, 1): y = Arr(i, 4)
If d.exists(x) = False Then Set d(x) = CreateObject("Scripting.Dictionary")
d(x)(y) = d(x)(y) & i & ","
Next
k = d.keys: t = d.items
For i = 0 To UBound(k)
kk = t(i).keys: tt = t(i).items
For ii = 0 To UBound(kk)
tt(ii) = Left(tt(ii), Len(tt(ii)) - 1)
If InStr(tt(ii), ",") Then
aa = Split(tt(ii), ",")
For j = 0 To UBound(aa)
Cells(aa(j), 4).Resize(1, 5).Interior.ColorIndex = 6
Next
End If
Next
Next
[al].CurrentRegion.Sort Keyl:=Range("A2"), Orderl:=xlAscending, Key2:=Range("D2"), Orderl:=xlAscending, Header:=xlYes
End Sub
|
|