|
Option Explicit
Const DELAY = 10
Dim tm, arr, brr, crr, cnt
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect([c7:e9], Target) Is Nothing Then Exit Sub
If Not IsArray(arr) Then MsgBox "先点击开始": Exit Sub
If Target.Count > 1 Or cnt = UBound(arr) Then Exit Sub
cnt = cnt + 1
arr(cnt) = Target.Value
If cnt = UBound(arr) Then
Dim i
For i = 1 To cnt
If arr(i) <> brr(1, i) Then Exit For
Next
MsgBox IIf(i = cnt + 1, "正确", "错误:" & Join(arr)) & vbNewLine & Format(Timer - tm, "用时0s")
Exit Sub
End If
If Timer - tm >= DELAY Then MsgBox "超时"
End Sub
Private Sub CommandButton1_Click()
brr = [c2:f2].Value: tm = Timer: cnt = 0
ReDim arr(1 To UBound(brr, 2))
End Sub |
|