I want to use this combobox menu dependently to access 10 different category menu with its sub-category, item, sub-item etc.
The vab code isn't displaying the menus with ID 10, 100, 101 etc, please how do I fix this? I have been on it for a week now, but no luck.
PLEASE HELP!!!
The vab code isn't displaying the menus with ID 10, 100, 101 etc, please how do I fix this? I have been on it for a week now, but no luck.
PLEASE HELP!!!
VBA Code:
Option Explicit
Dim id_line As Integer ' 加工ライン名のシート
Dim id_section As Integer ' メンテナス項目のシート
Dim id_koukan As Integer '交換ヶ所のシート
Dim id_subsection1 As Integer '交換部品その①のシート
Dim id_subsection2 As Integer '交換部品その②のシート
Private Sub cbo_Kakoumei_Change()
Dim a As Integer
Dim b As Integer
cbo_Section.Clear
With Sheet2 ' メンテナス項目のシート
id_line = cbo_Kakoumei.ListIndex + 1
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If Mid(.Cells(a, 1), 1, 1) = id_line Then
cbo_Section.AddItem (.Cells(a, 2))
End If
Next
End With
End Sub
Private Sub cbo_Section_Change()
Dim a As Integer
Dim b As Integer
cbo_KoukanKasho.Clear
With Sheet3 ' 交換ヶ所のシート
id_section = cbo_Section.ListIndex + 1
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If Mid(.Cells(a, 1), 1, 1) = id_line And _
Mid(.Cells(a, 1), 2, 1) = id_section Then
cbo_KoukanKasho.AddItem (.Cells(a, 2))
End If
Next
End With
End Sub
Private Sub cbo_KoukanKasho_Change()
Dim a As Integer
Dim b As Integer
cbo_Koukanbuhin1.Clear
With Sheet4 '交換部品その①のシート
id_koukan = cbo_KoukanKasho.ListIndex + 2
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If Mid(.Cells(a, 1), 1, 1) = id_line And _
Mid(.Cells(a, 1), 2, 1) = id_section And _
Mid(.Cells(a, 1), 3, 1) = id_koukan Then
cbo_Koukanbuhin1.AddItem (.Cells(a, 2))
End If
Next
End With
End Sub
Private Sub cbo_Koukanbuhin1_Change()
Dim a As Integer
Dim b As Integer
cbo_Koukanbuhin2.Clear
With Sheet5 '交換部品その②のシート
id_subsection1 = cbo_Koukanbuhin1.ListIndex + 2
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If Mid(.Cells(a, 1), 1, 1) = id_line And _
Mid(.Cells(a, 1), 2, 1) = id_section And _
Mid(.Cells(a, 1), 3, 1) = id_koukan And _
Mid(.Cells(a, 1), 4, 1) = id_subsection1 Then
cbo_Koukanbuhin2.AddItem (.Cells(a, 2))
End If
Next
End With
End Sub
Private Sub cbo_Koukanbuhin2_Change()
Dim a As Integer
Dim b As Integer
With Sheet5 '交換部品その②のシート
id_subsection2 = cbo_Koukanbuhin2.ListIndex + 2
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If Mid(.Cells(a, 1), 1, 1) = id_line And _
Mid(.Cells(a, 1), 2, 1) = id_section And _
Mid(.Cells(a, 1), 3, 1) = id_koukan And _
Mid(.Cells(a, 1), 4, 1) = id_subsection1 And _
Mid(.Cells(a, 1), 5, 1) = id_subsection2 Then
End If
Next
End With
End Sub
Private Sub UserForm_Initialize()
Dim a As Integer
Dim b As Integer
With Sheet1 '加工ライン名
b = .Cells(1, 1).End(xlDown).Row
For a = 2 To b
If .Cells(a, 1) <> "" Then
cbo_Kakoumei.AddItem (.Cells(a, 2))
End If
Next
End With
End Sub