Helo伙计们。有人可以帮我解决我的EXCEL VBA代码。我真的遇到了如何让我的FLASHCARD从Cell A1到最后一个单元格的OR ORDER出现问题。我有这个代码,但它只生成一个RANDOM单元格或值。我怎么能让它非随机?我知道通过使用代码RND,它会随机生成。但是NON RANDOM怎么样?
以下是代码:
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
希望你能帮助我解决这个问题。谢谢。
答案 0 :(得分:0)
取代:
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