M
mtm4300 via OfficeKB.com
Tom O. helped me with a problem I had creating a varying combo box. I used
the code, but I am still having errors. The purpose of the program is to
eliminate a variety of outputs for the user (42 in all). I have two option
butions that will run a combobox. Each combobox (I have two) has 3 different
choices. From there, the user will select one of the 3 choices. The user's
selection will run another combobox. This combobox has 7 choices for the user.
The following code is only a part of the code.
I get two errors when I run this.
- "Permission Denied"
- And then the ".Name" creates an error.
If anyone can offer me any help, I would appreciate it.
Sub optmeasureAmaj_Click()
If optmeasureE.Value = True Then
CreateAMajor
End If
End Sub
Sub optmeasureAmin_Click()
If optmeasureM.Value = True Then
CreateAMinor
End If
End Sub
Sub CreateAMajor()
With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=188, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 3
.ControlFormat.AddItem "A", 1
.ControlFormat.AddItem "B", 2
.ControlFormat.AddItem "C*", 3
.Name = "CreateAMajor"
.OnAction = "cboChoice"
End With
End Sub
Sub cboCoice()
Dim idex As Long
On Error Resume Next
Worksheets(1).DropDowns("cboChoice").Delete
On Error GoTo 0
idex = Worksheets(1).DropDowns("CreateAMajor").ListIndex
With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=359, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 7
.Name = "cboCoice"
Select Case idex
Case 1
.ControlFormat.AddItem "A1", 1
.ControlFormat.AddItem "A2", 2
.ControlFormat.AddItem "A3", 3
.ControlFormat.AddItem "A4", 4
.ControlFormat.AddItem "A5", 5
.ControlFormat.AddItem "A6", 6
.ControlFormat.AddItem "A7", 7
.OnAction = "cboChoiceA_Click"
Case 2
.ControlFormat.AddItem "B1", 1
.ControlFormat.AddItem "B2", 2
.ControlFormat.AddItem "B3", 3
.ControlFormat.AddItem "B4", 4
.ControlFormat.AddItem "B5", 5
.ControlFormat.AddItem "B6", 6
.ControlFormat.AddItem "B7", 7
.OnAction = "cboChoiceB_Click"
Case 3
.ControlFormat.AddItem "C1", 1
.ControlFormat.AddItem "C2", 2
.ControlFormat.AddItem "C3", 3
.ControlFormat.AddItem "C4", 4
.ControlFormat.AddItem "C5", 5
.ControlFormat.AddItem "C6", 6
.ControlFormat.AddItem "C7", 7
.OnAction = "cboChoiceC_Click"
End Select
End With
End Sub
the code, but I am still having errors. The purpose of the program is to
eliminate a variety of outputs for the user (42 in all). I have two option
butions that will run a combobox. Each combobox (I have two) has 3 different
choices. From there, the user will select one of the 3 choices. The user's
selection will run another combobox. This combobox has 7 choices for the user.
The following code is only a part of the code.
I get two errors when I run this.
- "Permission Denied"
- And then the ".Name" creates an error.
If anyone can offer me any help, I would appreciate it.
Sub optmeasureAmaj_Click()
If optmeasureE.Value = True Then
CreateAMajor
End If
End Sub
Sub optmeasureAmin_Click()
If optmeasureM.Value = True Then
CreateAMinor
End If
End Sub
Sub CreateAMajor()
With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=188, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 3
.ControlFormat.AddItem "A", 1
.ControlFormat.AddItem "B", 2
.ControlFormat.AddItem "C*", 3
.Name = "CreateAMajor"
.OnAction = "cboChoice"
End With
End Sub
Sub cboCoice()
Dim idex As Long
On Error Resume Next
Worksheets(1).DropDowns("cboChoice").Delete
On Error GoTo 0
idex = Worksheets(1).DropDowns("CreateAMajor").ListIndex
With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=359, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 7
.Name = "cboCoice"
Select Case idex
Case 1
.ControlFormat.AddItem "A1", 1
.ControlFormat.AddItem "A2", 2
.ControlFormat.AddItem "A3", 3
.ControlFormat.AddItem "A4", 4
.ControlFormat.AddItem "A5", 5
.ControlFormat.AddItem "A6", 6
.ControlFormat.AddItem "A7", 7
.OnAction = "cboChoiceA_Click"
Case 2
.ControlFormat.AddItem "B1", 1
.ControlFormat.AddItem "B2", 2
.ControlFormat.AddItem "B3", 3
.ControlFormat.AddItem "B4", 4
.ControlFormat.AddItem "B5", 5
.ControlFormat.AddItem "B6", 6
.ControlFormat.AddItem "B7", 7
.OnAction = "cboChoiceB_Click"
Case 3
.ControlFormat.AddItem "C1", 1
.ControlFormat.AddItem "C2", 2
.ControlFormat.AddItem "C3", 3
.ControlFormat.AddItem "C4", 4
.ControlFormat.AddItem "C5", 5
.ControlFormat.AddItem "C6", 6
.ControlFormat.AddItem "C7", 7
.OnAction = "cboChoiceC_Click"
End Select
End With
End Sub