|
|

楼主 |
发表于 2009-8-6 11:57
|
显示全部楼层
我的方法大概要23-24分钟:
Option Base 1
Sub Macro1()
t = Timer
Dim R, R1, Rt(), dic As New Dictionary
With Sheets("数据")
n = .[l65536].End(3).Row
R = .Range("a1:l" & n)
ReDim Rt(n, 12)
For i = 1 To n
R1 = Application.Index(R, i, 0)
If Not IsCF(R1, dic) Then
dic(R1(1) & " " & R1(2) & " " & R1(3) & " " & R1(4) & " " & R1(5) & " " & R1(6) & " " & R1(7) & " " & R1(8) _
& " " & R1(9) & " " & R1(10) & " " & R1(11) & " " & R1(12)) = ""
End If
Application.StatusBar = "正在检测..." & "已经检测第:" & i & "行。"
DoEvents
Next
.[n1].Resize(dic.Count) = Application.Transpose(dic.Keys)
End With
MsgBox Timer - t
Set D = Nothing
End Sub
Public Function IsCF(R, D As Dictionary) As Boolean
IsCF = False
If D.Exists(R(1) & " " & R(2) & " " & R(3) & " " & R(4) & " " & R(5) & " " & R(6) & " " & R(7) & " " & R(8) _
& " " & R(9) & " " & R(10) & " " & R(11) & " " & R(12)) Then IsCF = True: Exit Function
If D.Exists(R(3) & " " & R(4) & " " & R(5) & " " & R(6) & " " & R(7) & " " & R(8) & " " & R(9) & " " & R(10) _
& " " & R(11) & " " & R(12) & " " & R(1) & " " & R(2)) Then IsCF = True: Exit Function
If D.Exists(R(5) & " " & R(6) & " " & R(7) & " " & R(8) & " " & R(9) & " " & R(10) & " " & R(11) & " " & R(12) _
& " " & R(1) & " " & R(2) & " " & R(3) & " " & R(4)) Then IsCF = True: Exit Function
If D.Exists(R(7) & " " & R(8) & " " & R(9) & " " & R(10) & " " & R(11) & " " & R(12) & " " & R(1) & " " & R(2) _
& " " & R(3) & " " & R(4) & " " & R(5) & " " & R(6)) Then IsCF = True: Exit Function
If D.Exists(R(9) & " " & R(10) & " " & R(11) & " " & R(12) & " " & R(1) & " " & R(2) & " " & R(3) & " " & R(4) _
& " " & R(5) & " " & R(6) & " " & R(7) & " " & R(8)) Then IsCF = True: Exit Function
If D.Exists(R(11) & " " & R(12) & " " & R(1) & " " & R(2) & " " & R(3) & " " & R(4) & " " & R(5) & " " & R(6) _
& " " & R(7) & " " & R(8) & " " & R(9) & " " & R(10)) Then IsCF = True: Exit Function
If D.Exists(R(1) & " " & R(12) & " " & R(11) & " " & R(10) & " " & R(9) & " " & R(8) & " " & R(7) & " " & R(6) _
& " " & R(5) & " " & R(4) & " " & R(3) & " " & R(2)) Then IsCF = True: Exit Function
If D.Exists(R(11) & " " & R(10) & " " & R(9) & " " & R(8) & " " & R(7) & " " & R(6) & " " & R(5) & " " & R(4) _
& " " & R(3) & " " & R(2) & " " & R(1) & " " & R(12)) Then IsCF = True: Exit Function
If D.Exists(R(9) & " " & R(8) & " " & R(7) & " " & R(6) & " " & R(5) & " " & R(4) & " " & R(3) & " " & R(2) _
& " " & R(1) & " " & R(12) & " " & R(11) & " " & R(10)) Then IsCF = True: Exit Function
If D.Exists(R(7) & " " & R(6) & " " & R(5) & " " & R(4) & " " & R(3) & " " & R(2) & " " & R(1) & " " & R(12) _
& " " & R(11) & " " & R(10) & " " & R(9) & " " & R(8)) Then IsCF = True: Exit Function
If D.Exists(R(5) & " " & R(4) & " " & R(3) & " " & R(2) & " " & R(1) & " " & R(12) & " " & R(11) & " " & R(10) _
& " " & R(9) & " " & R(8) & " " & R(7) & " " & R(6)) Then IsCF = True: Exit Function
If D.Exists(R(3) & " " & R(2) & " " & R(1) & " " & R(12) & " " & R(11) & " " & R(10) & " " & R(9) & " " & R(8) _
& " " & R(7) & " " & R(6) & " " & R(5) & " " & R(4)) Then IsCF = True: Exit Function
End Function |
|