|
发表于 2013-9-21 07:34
|
显示全部楼层
本楼为最佳答案
- Sub test()
- Dim arr, arr2(1 To 1000, 1 To 1), k As Integer
- Dim lLastRow As Long
- lLastRow = Cells(Rows.Count, "f").End(xlUp).Row
- arr = Range(Range("f2"), Cells(lLastRow, "g")).Value
- Dim objDic As Object
- On Error Resume Next
- Set objDic = CreateObject("scripting.dictionary")
- For i = LBound(arr) To UBound(arr) Step 9
- For j = 0 To 8
- If Len(arr(i + j, 1)) Then
- objDic(arr(i + j, 1)) = objDic(arr(i + j, 1)) + 1
- End If
- Next
- For Each Key In objDic.keys
- If objDic(Key) > 1 Then
- k = k + 1
- arr2(k, 1) = "'" & Key
- End If
- Next
- objDic.RemoveAll
- Next
- Set objDic = Nothing
- If k Then
- Range("h2").Resize(k).Value = arr2
- MsgBox "数据提取完成"
- Else
- MsgBox "没有符合要求的数据"
- End If
-
- End Sub
复制代码 |
|