|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Private Sub ListBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
- Dim i&, aa$
- If KeyCode = 13 Then
- For i = 0 To ListBox1.ListCount - 1
- If ListBox1.Selected(i) = True Then
- aa = aa & ListBox1.List(i) & " "
- End If
- Next
- ActiveCell.Value = aa
- ListBox1.Visible = False
- End If
- End Sub
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim Myr&, Arr
- If Target.Count > 1 Then Me.ListBox1.Visible = False: Exit Sub
- If Target.Column <> 9 And Target.Column <> 10 Then Me.ListBox1.Visible = False: Exit Sub
- If Target.Column = 9 Then
- Myr = Cells(Rows.Count, "XFB").End(xlUp).Row
- Arr = Range("xfb2:xfb" & Myr)
- Else
- Myr = Cells(Rows.Count, "XFc").End(xlUp).Row
- Arr = Range("xfc2:xfc" & Myr)
- End If
- With Me.ListBox1
- .Clear
- .List = Application.Index(Arr, 0, 1)
- .Left = Target.Left + Target.Width
- .Top = ActiveCell.Top
- .Width = ActiveCell.Width * 1.4
- .Height = ActiveCell.Height * 8
- .Visible = True
- End With
- End Sub
复制代码 |
|