|
看是不是你要的效果- Private dic As Object
-
- Private Sub ListBox1_Click()
- ListBox2.Clear
- ListBox3.Clear
- ListBox2.List = dic(ListBox1.Text).keys
- End Sub
- Private Sub ListBox2_Click()
- ListBox3.Clear
- ListBox3.List = dic(ListBox1.Text)(ListBox2.Text).keys
- End Sub
- Private Sub ListBox3_Click()
- ActiveCell = ListBox1.Text
- ActiveCell.Offset(, 1) = ListBox2.Text
- ActiveCell.Offset(, 2) = ListBox3.Text
- Unload Me
- End Sub
- Private Sub UserForm_Initialize()
- Dim i As Long, arr(), j As Long, c(1 To 4) As String
- Set dic = Nothing
- Set dic = CreateObject("Scripting.Dictionary")
- arr = Sheets("产品规格").Cells(1, 1).CurrentRegion.Value
- For i = 1 To UBound(arr)
- For j = 1 To 4
- c(j) = arr(i, j)
- Next
- If Not dic.Exists(c(2)) Then Set dic(c(2)) = CreateObject("Scripting.Dictionary")
- If Not dic(c(2)).Exists(c(3)) Then Set dic(c(2))(c(3)) = CreateObject("Scripting.Dictionary")
- If Not dic(c(2))(c(3)).Exists(c(4)) Then Set dic(c(2))(c(3))(c(4)) = CreateObject("Scripting.Dictionary")
- Next
- ListBox1.List = dic.keys
- End Sub
- Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
- Unload Me
- Set dic = Nothing
- End Sub
复制代码
|
-
-
-
例子.rar
105.02 KB, 下载次数: 529
附件
|