学习下递归,提供另一种思路: Dim iCel As Integer Dim iStop As Integer Dim iStep As Integer Sub d(ByVal iCount As Integer, Ar) Dim i As Integer Dim tmAr() As Integer If iCount = iStep Then Cells(iCel, "g").Resize(1, UBound(Ar)) = Ar iCel = iCel + 1 Exit Sub End If For i = 1 To iStop If IsError(Application.Match(i, Ar, 0)) Then If i > Application.Max(Ar) Then Ar(iCount + 1) = i tmAr = Ar d iCount + 1, tmAr End If End If Next End Sub Sub f() iCel = 3 iStop = Val(Sheet1.TextBox1.Text) iStep = Val(Sheet1.TextBox2.Text) Dim Ar() As Integer ReDim Ar(1 To iStep) d 0, Ar End Sub
|