listbox 如何实现多列多选 40
我在D列已经实现多选,但F列也要实现不知怎么改如下代码,求大神告知,谢谢!PrivateSubListBox1_Change()IfReLoadThenExitSub'见...
我在D列已经实现多选,但F列也要实现不知怎么改如下代码,求大神告知,谢谢!
Private Sub ListBox1_Change()
If ReLoad Then Exit Sub '见下方说明
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then t = t & "," & ListBox1.List(i)
Next
ActiveCell = Mid(t, 2)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ListBox1
If ActiveCell.Column = 4 And ActiveCell.Row > 1 Then
t = ActiveCell.Value
ReLoad = True '如果是根据单元格的值修改列表框,则暂时屏蔽listbox的change事件。
For i = 0 To .ListCount - 1 '根据活动单元格内容修改列表框中被选中的内容
If InStr(t, .List(i)) Then
.Selected(i) = True
Else
.Selected(i) = False
End If
Next
ReLoad = False
.Top = ActiveCell.Top + ActiveCell.Height '以下语句根据活动单元格位置显示列表框
.Left = ActiveCell.Left
.Width = ActiveCell.Width
.Visible = True
Else
.Visible = False
End If
End With
End Sub
没有回答如何关闭 展开
Private Sub ListBox1_Change()
If ReLoad Then Exit Sub '见下方说明
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then t = t & "," & ListBox1.List(i)
Next
ActiveCell = Mid(t, 2)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ListBox1
If ActiveCell.Column = 4 And ActiveCell.Row > 1 Then
t = ActiveCell.Value
ReLoad = True '如果是根据单元格的值修改列表框,则暂时屏蔽listbox的change事件。
For i = 0 To .ListCount - 1 '根据活动单元格内容修改列表框中被选中的内容
If InStr(t, .List(i)) Then
.Selected(i) = True
Else
.Selected(i) = False
End If
Next
ReLoad = False
.Top = ActiveCell.Top + ActiveCell.Height '以下语句根据活动单元格位置显示列表框
.Left = ActiveCell.Left
.Width = ActiveCell.Width
.Visible = True
Else
.Visible = False
End If
End With
End Sub
没有回答如何关闭 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询