|
- Sub tttt()
- Set d = CreateObject("scripting.dictionary")
- arr = Range("f3").CurrentRegion
- For j = 1 To UBound(arr, 2)
- For i = 1 To UBound(arr)
- x = arr(i, j)
- If Not d.exists(x) Then
- d(x) = "," & j & ","
- Else
- If InStr(d(x), "," & j & ",") = 0 Then d(x) = d(x) & j & ","
- End If
- Next
- Next
-
- ReDim brr(1 To d.Count, 1 To 2)
- dk = d.keys: dt = d.items
- For i = 1 To d.Count
- x = dk(i - 1): y = dt(i - 1)
- xstr = ""
- For j = 1 To UBound(arr, 2) - 5
- xstr = "," & j & "," & j + 1 & "," & j + 2 & "," & j + 3 & "," & j + 4 & "," & j + 5 & ","
- If InStr(y, xstr) > 0 Then
- n = n + 1
- brr(n, 1) = "'" & x
- brr(n, 2) = Mid(xstr, 2, Len(xstr) - 2)
- Exit For
- End If
- Next
- Next
- [a:b].Clear
- [a1] = "值": [b1] = "连续列"
- Range("a2").Resize(d.Count, 2) = brr
- End Sub
复制代码 |
|