|
'参与一下,123楼附件,,,
Option Explicit
Dim lastvalue(1), lastpos, combarr
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i
If Target.Rows.Count + Target.Columns.Count > 2 Then Exit Sub
If Intersect([c35:c36], Target) Is Nothing Then Exit Sub
If lastvalue(0) <> [c32].Value Or lastvalue(1) <> [c33].Value Then Call init
If Target.Address = "$C$36" Then
lastpos = lastpos + 1
If lastpos > UBound(combarr, 1) Then lastpos = 1
Else
lastpos = lastpos - 1
If lastpos < 1 Then lastpos = UBound(combarr, 1)
End If
For i = 1 To 3
Cells(30, i + 6) = combarr(lastpos, i)
Next
Target.Offset(, 1).Select
End Sub
Function init()
Dim i, j, k, m, n, cnt, a, b
On Error GoTo errmsg
a = [c32].Value: b = [c33].Value
cnt = b - a + 1: n = 1
For i = cnt - 2 To cnt
n = n * i
Next
n = n / 6
If n > 10 ^ 5 Then MsgBox Format(n, "组数是否太多0"): Exit Function
ReDim combarr(1 To n, 1 To 3)
For i = a To b - 2
For j = i + 1 To b - 1
For k = j + 1 To b
m = m + 1
combarr(m, 1) = i: combarr(m, 2) = j: combarr(m, 3) = k
Next
Next
Next
lastvalue(0) = a: lastvalue(1) = b
lastpos = 0
Exit Function
errmsg:
MsgBox "检查输入数据!"
End Function |
评分
-
1
查看全部评分
-
|