|
发表于 2012-11-16 16:57
|
显示全部楼层
本楼为最佳答案
- Sub lqxs()
- Dim Arr, i&, x$, j&, aa, ks, js
- Dim d, k, t, bb
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Sheet1.Activate
- Arr = [a1].CurrentRegion
- For i = 2 To UBound(Arr)
- x = Arr(i, 5) & "," & Arr(i, 6)
- d(x) = d(x) & i & ","
- Next
- k = d.keys
- t = d.items
- [k4].Resize(d.Count) = Application.Transpose(k)
- [k4].Resize(d.Count).TextToColumns Comma:=True
- For i = 0 To UBound(k)
- t(i) = Left(t(i), Len(t(i)) - 1)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- ReDim bb(UBound(aa))
- For j = 0 To UBound(aa)
- bb(j) = Arr(aa(j), 8)
- Next
- ks = Application.Min(bb)
- js = Application.Max(bb)
- Cells(i + 4, 13) = ks & "-" & js
- Else
- Cells(i + 4, 13) = t(i)
- End If
- Cells(i + 4, 10) = i + 1
- Next
- Application.DisplayAlerts = True
- End Sub
复制代码 |
|