Sub select_random_Question()
Dim varList As Variant, total_numbers As Long, str1 As String, str2 As String
'Dim start_range As Long
'Dim end_range As Long
Set se = Sheets("se")
se.Activate
str1 = "Number of Questions to attempt the Quiz"
str2 = "Note:Random Questions will be Displayed"
total_numbers = InputBox(str1 & vbCrLf & str2)
'start_range = InputBox("Please enter the starting range")
'end_range = InputBox("Please enter the ending range")
varList = Random_Numbers(total_numbers, 1, total_numbers)
Set coll1 = New Collection
se.Range(Cells(1, 1), Cells(total_numbers, 1)).Value = Application.Transpose(varList)
For j = 1 To total_numbers
myNum = Sheets("se").Cells(j, 1).Value
Dim optbtn As MSForms.UserForm
Dim usrfm As MSForms.OptionButton
'coll1.Add myNum
'Debug.Print coll1(j)
'MsgBox myNum
If IsLoaded("UserForm" & myNum + 1) Then
MsgBox "Yes"
Else
For x = 2 To 5
If Sheets("Answers").Cells(x, myNum).Value = "" Then
'Do Nothing
Else
z1 = Sheets("Answers").Cells(x, myNum).Value
For z2 = 1 To 4
Set usrfm = "UserForm" & myNum + 1 'This is where im get stuck
Set optbtn = "OptionButton" & z2
'With usrfm
'.optbtn.Caption
'End With
Next z2
End If
Next x
End If
Select Case myNum
Case Is = 1: UserForm2.Show
Case Is = 2: UserForm3.Show
Case Is = 3: UserForm4.Show
Case Is = 4: UserForm5.Show
Case Is = 5: UserForm6.Show
Case Is = 6: UserForm7.Show
Case Is = 7: UserForm8.Show
Case Is = 8: UserForm9.Show
Case Is = 9: UserForm10.Show
Case Is = 10: UserForm11.Show
Case Is = 11: UserForm12.Show
Case Is = 12: UserForm13.Show
Case Is = 13: UserForm14.Show
Case Is = 14: UserForm15.Show
Case Is = 15: UserForm16.Show
Case Is = 16: UserForm17.Show
Case Is = 17: UserForm18.Show
Case Is = 18: UserForm19.Show
Case Is = 19: UserForm20.Show
Case Is = 20: UserForm21.Show
Case Is = 21: UserForm22.Show
Case Is = 22: UserForm23.Show
Case Is = 23: UserForm24.Show
Case Is = 24: UserForm25.Show
Case Is = 25: UserForm26.Show
Case Is = 26: UserForm27.Show
Case Is = 27: UserForm28.Show
Case Is = 28: UserForm29.Show
End Select
Next j
End Sub
я использую случайную функцию, чтобы получить случайное число, используя это случайное число, я выбираю пользовательскую форму ... в этой пользовательской форме у меня есть вопрос "Какая столица штата является патной", выбирая соответствующая опция и сохранение ответа на листе «Ответы», но перед тем, как получить пользовательскую форму, я проверяю, сохранен или нет этот пользовательский ответ.
Я пытаюсь получить Userform1.Optionbutton1.caption динамически. , то есть «UserForm» & myNum для получения userform1 и использование для l oop для итерации по значениям optionbutton. , как мне это получить ??
Заранее спасибо