N
netsurfer802
Hi Programmers:
I'm having a difficult time running a macro in Excel that is supposed
to make a dialog box come up with various options with check boxes.
Every time it is run I get:
Run-time error "9": Subscript out of range
When I choose Debug it brings me to the line that I've put an arror
next to:
Set OptionsDlg = ThisWorkbook.DialogSheets("OptionsDlg")<--------------(See
below). I've tried looking up in help what it means but I just
get lost, as it defines it as an issue with an array. Don't
understand
what it would have to do with an array.
Thanks for any response.
===========================================================================
Sub SetOptions()
' Set the options for the Quizzes
Dim OptionsDlg As Object
Dim Admin As Object
Dim item As Object
Dim OptionsOK As Integer
Set OptionsDlg =
ThisWorkbook.DialogSheets("OptionsDlg")<----------------
Set Admin = ThisWorkbook.Worksheets("Admin")
' Make sure there is at least one quiz sheet
If QuizCount() = 0 Then
MsgBox "There are no Quizzes in " & ThisWorkbook.Name,
vbExclamation, AppName
End
End If
' Get current settings stored in Admin worksheet
OptionsDlg.CheckBoxes.Value = xlOff
If Admin.Range("BackTrack") = True Then _
OptionsDlg.CheckBoxes("cbBacktrack") = xlOn
If Admin.Range("DisplayScores") = True Then _
OptionsDlg.CheckBoxes("cbDisplayScores") = xlOn
If Admin.Range("DisplayTime") = True Then _
OptionsDlg.CheckBoxes("cbDisplayTime") = xlOn
If Admin.Range("AllowReview") = True Then _
OptionsDlg.CheckBoxes("cbAllowReview") = xlOn
If Admin.Range("SaveResults") = True Then _
OptionsDlg.CheckBoxes("cbSaveResults") = xlOn
If Admin.Range("HideStuff") = True Then _
OptionsDlg.CheckBoxes("cbHideStuff") = xlOn
' Show the dialog
OptionsOK = OptionsDlg.Show
If Not OptionsOK Then End
' Transfer dialog box info to Admin worksheet
If OptionsDlg.CheckBoxes("cbBacktrack") = xlOn Then _
Admin.Range("BackTrack") = True _
Else Admin.Range("BackTrack") = False
If OptionsDlg.CheckBoxes("cbDisplayScores") = xlOn Then _
Admin.Range("DisplayScores") = True _
Else Admin.Range("DisplayScores") = False
If OptionsDlg.CheckBoxes("cbDisplayTime") = xlOn Then _
Admin.Range("DisplayTime") = True _
Else Admin.Range("DisplayTime") = False
If OptionsDlg.CheckBoxes("cbAllowReview") = xlOn Then _
Admin.Range("AllowReview") = True _
Else Admin.Range("AllowReview") = False
If OptionsDlg.CheckBoxes("cbSaveResults") = xlOn Then _
Admin.Range("SaveResults") = True _
Else Admin.Range("SaveResults") = False
If OptionsDlg.CheckBoxes("cbHideStuff") = xlOn Then
Admin.Range("HideStuff") = True
QuizMode
End If
If OptionsDlg.CheckBoxes("cbHideStuff") = xlOff Then
Admin.Range("HideStuff") = False
AdminMode
End If
End Sub
I'm having a difficult time running a macro in Excel that is supposed
to make a dialog box come up with various options with check boxes.
Every time it is run I get:
Run-time error "9": Subscript out of range
When I choose Debug it brings me to the line that I've put an arror
next to:
Set OptionsDlg = ThisWorkbook.DialogSheets("OptionsDlg")<--------------(See
below). I've tried looking up in help what it means but I just
get lost, as it defines it as an issue with an array. Don't
understand
what it would have to do with an array.
Thanks for any response.
===========================================================================
Sub SetOptions()
' Set the options for the Quizzes
Dim OptionsDlg As Object
Dim Admin As Object
Dim item As Object
Dim OptionsOK As Integer
Set OptionsDlg =
ThisWorkbook.DialogSheets("OptionsDlg")<----------------
Set Admin = ThisWorkbook.Worksheets("Admin")
' Make sure there is at least one quiz sheet
If QuizCount() = 0 Then
MsgBox "There are no Quizzes in " & ThisWorkbook.Name,
vbExclamation, AppName
End
End If
' Get current settings stored in Admin worksheet
OptionsDlg.CheckBoxes.Value = xlOff
If Admin.Range("BackTrack") = True Then _
OptionsDlg.CheckBoxes("cbBacktrack") = xlOn
If Admin.Range("DisplayScores") = True Then _
OptionsDlg.CheckBoxes("cbDisplayScores") = xlOn
If Admin.Range("DisplayTime") = True Then _
OptionsDlg.CheckBoxes("cbDisplayTime") = xlOn
If Admin.Range("AllowReview") = True Then _
OptionsDlg.CheckBoxes("cbAllowReview") = xlOn
If Admin.Range("SaveResults") = True Then _
OptionsDlg.CheckBoxes("cbSaveResults") = xlOn
If Admin.Range("HideStuff") = True Then _
OptionsDlg.CheckBoxes("cbHideStuff") = xlOn
' Show the dialog
OptionsOK = OptionsDlg.Show
If Not OptionsOK Then End
' Transfer dialog box info to Admin worksheet
If OptionsDlg.CheckBoxes("cbBacktrack") = xlOn Then _
Admin.Range("BackTrack") = True _
Else Admin.Range("BackTrack") = False
If OptionsDlg.CheckBoxes("cbDisplayScores") = xlOn Then _
Admin.Range("DisplayScores") = True _
Else Admin.Range("DisplayScores") = False
If OptionsDlg.CheckBoxes("cbDisplayTime") = xlOn Then _
Admin.Range("DisplayTime") = True _
Else Admin.Range("DisplayTime") = False
If OptionsDlg.CheckBoxes("cbAllowReview") = xlOn Then _
Admin.Range("AllowReview") = True _
Else Admin.Range("AllowReview") = False
If OptionsDlg.CheckBoxes("cbSaveResults") = xlOn Then _
Admin.Range("SaveResults") = True _
Else Admin.Range("SaveResults") = False
If OptionsDlg.CheckBoxes("cbHideStuff") = xlOn Then
Admin.Range("HideStuff") = True
QuizMode
End If
If OptionsDlg.CheckBoxes("cbHideStuff") = xlOff Then
Admin.Range("HideStuff") = False
AdminMode
End If
End Sub