|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Dim rng As Range
- Private Sub ListBox1_GotFocus()
- With Me.ListBox1
- .Clear
- .AddItem "选项1"
- .AddItem "选项2"
- .AddItem "选项3"
- .AddItem "选项4"
- .AddItem "选项5"
- .AddItem "选项6"
- End With
- End Sub
- Private Sub ListBox1_LostFocus()
- Dim str As String, i As Integer
- str = ""
- For i = 0 To Me.ListBox1.ListCount - 1
- If Me.ListBox1.Selected(i) Then
- str = str & "," & Me.ListBox1.List(i)
- End If
- Next i
- rng.Value = Right(str, Len(str) - 1)
- Me.ListBox1.Clear
- Me.ListBox1.Visible = False
- End Sub
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- If Target.Column = 2 Then
- With Me.ListBox1
- .Visible = True
- .Clear
- .AddItem "选项1"
- .AddItem "选项2"
- .AddItem "选项3"
- .AddItem "选项4"
- .AddItem "选项5"
- .AddItem "选项6"
- .Top = Target.Top
- .Left = Target.Left + Target.Width
- ' .Height = Target.Height
- End With
- Set rng = Target
- Else
- With Me.ListBox1
- .Visible = False
- End With
- End If
- End Sub
复制代码 |
|