|
こんにちは
どのように作りましたか?
例:
A B C
1 AA BB CC ←ComboBox1の値
2 AA_1 BB_1 CC_1 ←ComboBox2の値
3 AA_2 BB_2 CC_2 .
4 AA_3 BB_3 CC_3 .
5 AA_4 BB_4 CC_4 .
1行目をComboBox1にセット
ComboBox1の値により各列の2行目からのデータをComboBox2にセット
こんな感じです。
Dim Da As Variant
Private Sub ComboBox1_Change()
Dim i As Long, ii As Long
Me.ComboBox2.Clear
With Worksheets("Sheet1")
For i = 1 To .Range("A1").End(xlToRight).Column
If Me.ComboBox1.Value = Da(1, i) Then
For ii = 2 To Cells(.Rows.Count, i).End(xlUp).Row
Me.ComboBox2.AddItem Da(ii, i)
Next ii
Exit For
End If
Next i
End With
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
With Worksheets("Sheet1")
Da = Range("A1").CurrentRegion.Value
For i = 1 To .Range("A1").End(xlToRight).Column
Me.ComboBox1.AddItem Da(1, i)
Next i
End With
End Sub
|
|