|
- Public d As Object
- Private Sub cmd_exit_Click()
- Unload userform1
- End Sub
- Private Sub cmd_ok_Click()
- Dim rng As Range
- With Me
- If .ComboBox1.ListIndex = -1 Then
- Exit Sub
- End If
- With Worksheets("BBB")
- .Cells.Clear
- End With
- d(.ComboBox1.Text).Copy Worksheets("BBB").Range("a1")
- Unload userform1
- End With
- End Sub
- Private Sub UserForm_Initialize()
- Dim r%, i%
- Dim arr, brr
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("AAA")
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- arr = .Range("a1:a" & r)
- For i = 1 To UBound(arr)
- If Len(arr(i, 1)) <> 0 Then
- c = .Cells(i, .Columns.Count).End(xlToLeft).Column
- r = .Cells(i, 2).End(xlDown).Row
- Set d(arr(i, 1)) = .Range(.Cells(i, 2), .Cells(r, c))
- End If
- Next
- End With
- With Me
- With .ComboBox1
- .List = d.keys
- End With
- End With
- End Sub
复制代码 |
|