Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在EXCEL VBA中创建非随机_Excel_Vba - Fatal编程技术网

如何在EXCEL VBA中创建非随机

如何在EXCEL VBA中创建非随机,excel,vba,Excel,Vba,大家好。有人能帮我解决我的EXCEL VBA代码吗。我真的很难让我的抽认卡从A1单元按顺序显示到最后一个单元。我有这个代码,但它只生成一个随机单元格或值。我怎样才能使它非随机?我知道通过使用代码RND,它会随机生成。但是非随机的呢 代码如下: Private Sub NextCard() Application.ScreenUpdating = False Dim finalTermRow As Integer finalTermRow = Range("a60000").End(xlUp).

大家好。有人能帮我解决我的EXCEL VBA代码吗。我真的很难让我的抽认卡从A1单元按顺序显示到最后一个单元。我有这个代码,但它只生成一个随机单元格或值。我怎样才能使它非随机?我知道通过使用代码RND,它会随机生成。但是非随机的呢

代码如下:

Private Sub NextCard()
Application.ScreenUpdating = False

Dim finalTermRow As Integer
finalTermRow = Range("a60000").End(xlUp).Row

Dim possibleRow As Integer
Dim foundTerm As Boolean
foundTerm = False
Dim tries As Integer
tries = 0

Do While foundTerm = False And tries < 1000
    possibleRow = Rnd() * (finalTermRow - 2) + 2

    If Cells(possibleRow, 4).Value = "" Then
        If possibleRow <> previousRow Then
            foundTerm = True
        End If
    End If
    tries = tries + 2
Loop

Application.ScreenUpdating = True

If tries < 1000 Then
    currentRow = possibleRow
    BoxQuestion.Text = Cells(currentRow, 1).Value
    BoxDefinition.Text = ""
    AltBox.Text = ""
Else
    MsgBox ("There are no other cards to go to--you've learned everything else!  Congratulations!  To study all your cards again, click reset.")
End If
End Sub
希望你们能帮我解决这个问题。谢谢。

替换:

tries = 0
Do While foundTerm = False And tries < 1000
  possibleRow = Rnd() * (finalTermRow - 2) + 2


谢谢加里的学生。我试过这个代码,它成功了。但是只有两张牌。如果我有更多的牌怎么办?
tries = 0
possibleRow=0
Do While foundTerm = False And tries < 1000
   possibleRow = possibleRow + 1