【发布时间】:2015-04-01 06:29:22
【问题描述】:
伙计们。有人可以帮我解决我的 EXCEL VBA 代码。我真的很难让我的 FLASHCARD 从单元格 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
希望你们能帮我解决这个问题。谢谢。
【问题讨论】: