나는 여러 개의 종속적 인 Comboboxes를 가진 userform을 가지고있다. Comboboxes Change 이벤트에 다음 코드를 추가하고 싶습니다. 코딩해야 할 콤보 박스는 번호가 11에서 20 (Combobox11, Combobox 12 등)이며 종속 콤보 박스는 21에서 30으로 번호가 매겨집니다.코드 comboboxes on excel userform
코드를 10 번 복사하여 붙여 넣은 다음 해당 콤보 박스 번호
이것을 달성하기 위해 콤보 상자를 통해 루프를 사용하는 방법이 있습니까? 도움이된다면 가장 감사 할 것입니다.
Private Sub ComboBox11_Change()
Dim index As Integer
index = ComboBox11.ListIndex
ComboBox21.Clear
Select Case index
Case Is = 0
With ComboBox21
.RowSource = Range("SubCat1").Address(external:=True)
End With
Case Is = 1
With ComboBox21
.RowSource = Range("SubCat6").Address(external:=True)
End With
Case Is = 2
With ComboBox21
.RowSource = Range("SubCat7").Address(external:=True)
End With
Case Is = 3
With ComboBox21
.RowSource = Range("SubCat8").Address(external:=True)
End With
Case Is = 4
With ComboBox21
.RowSource = Range("SubCat9").Address(external:=True)
End With
'and several more case options
End Select
End Sub
의 당신이 UserForm_Initialize 절차를 의미합니까. 거기에 코드를 넣었지만 사용자 폼을로드했을 때 콤보 상자에 항목이 없었습니다. – willi
@willi'Set Obj = Nothing' 라인 다음에 위 코드에'UserForm_Initialize'의 원본 코드를 추가해야합니다. –
코드를 UserForm_ initialize 프로 시저에 추가했지만 Option Explicit 또는 Dim 문 "ComboBoxCounter As Integer, Obj As Control"을 하위 이름 위에 두지 않습니다. 내가 뭘 놓치고 있니? 나는 며칠 동안 사무실에서 나갈 것이다. – willi