VB listbox多选(以下代码复制后只能单选,不能多选),求修改为多选,在线等.... 10
PrivateSubListBox1_KeyUp(ByValKeyCodeAsMSForms.ReturnInteger,ByValShiftAsInteger)Dimi...
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 <> 4 Then Me.ListBox1.Visible = False: Exit Sub
If Target.Column = 4 Then
Myr = Cells(Rows.Count, "AA").End(xlUp).Row
Arr = Range("AA2:aa" & 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 展开
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 <> 4 Then Me.ListBox1.Visible = False: Exit Sub
If Target.Column = 4 Then
Myr = Cells(Rows.Count, "AA").End(xlUp).Row
Arr = Range("AA2:aa" & 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 展开
展开全部
listBox1.SelectionMode = SelectionMode.MultiSimple;多项 listBox1.SelectionMode = SelectionMode.One ; 单项
追问
修改哪个地方?能多选、单选及删除都ok
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询