首页 > 解决方案 > 仅按行随机播放二维数组

问题描述

我正在 Excel 中进行多项选择测验,该测验将显示在 userForm 上。数据在工作表“tempSheet”中,其中包含 D 列中的问题,给定问题的三个选项在 E(“正确的一个”)、F 和 G 列中。我将三个答案加载到二维数组中,以及答案是否正确。

有人可以在表单上使用它之前帮我洗牌这个数组的行吗?我试图阻止正确的答案始终是第一选择。

非常感谢您提前

以下代码只是将信息加载到数组的部分。

子 multChce()

Dim myQstnCell As Range
Dim mChoices(2, 1)

Set myQstnCell = Range("D2")

'Questions are in column D. The correct answer in Column E, then two distractors in F and G
mChoices(0, 0) = myQstnCell.Offset(0, 1).Value
mChoices(0, 1) = "Correct"
mChoices(1, 0) = myQstnCell.Offset(0, 2).Value
mChoices(1, 1) = "Incorrect"
mChoices(2, 0) = myQstnCell.Offset(0, 3).Value
mChoices(2, 1) = "Incorrect"



'answers will be displayed on option buttons
ans_frm.choiceA_Btn.Caption = mChoices(0, 0)
ans_frm.choiceB_Btn.Caption = mChoices(1, 0)
ans_frm.choiceC_Btn.Caption = mChoices(2, 0)



End Sub

标签: arraysexcel

解决方案


推荐阅读