|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim arrlist As Object
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Set arrlist = CreateObject("system.collections.arraylist")
- With Worksheets("01")
- r = Application.Max(.Cells(.Rows.Count, 2).End(xlUp).Row, .Cells(.Rows.Count, 3).End(xlUp).Row)
- arr = .Range("b2:c" & r)
- For j = 1 To 2
- For i = 1 To UBound(arr)
- If Len(arr(i, j)) <> 0 Then
- arrlist.Clear
- For k = 1 To Len(arr(i, j))
- ch = Val(Mid(arr(i, j), k, 1))
- arrlist.Add ch
- Next
- arrlist.Sort
- ss = Join(arrlist.toarray, "")
- If Not d.exists(ss) Then
- Set d(ss) = CreateObject("scripting.dictionary")
- End If
- d(ss)(j) = arr(i, j)
- End If
- Next
- Next
- ReDim brr(1 To UBound(arr) * 2, 1 To 1)
- m = 0
- For Each aa In d.keys
- If d(aa).Count = 2 Then
- m = m + 1
- brr(m, 1) = d(aa)(1)
- End If
- Next
- .Range("f2:f" & .Rows.Count).ClearContents
- .Range("f2").Resize(m, 1) = brr
- End With
- End Sub
复制代码 |
|