|
跟老师学习下。谢谢老师!
Private Sub Worksheet_SelectionChange(ByVal T As Range)
If T.Column <> 13 Then ListBox1.Visible = False
If T.Row > 1 And T.Column = 13 Then
If T.Count > 1 Then Exit Sub
If T.Value = "" Then Exit Sub
ar = Sheets("领用记录").[a1].CurrentRegion
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
n = 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(1, j)
Next j
For i = 2 To UBound(ar)
If Trim(ar(i, 3)) = Trim(T.Value) Then
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
Next i
' Cancel = True
If n = 1 Then ListBox1.Visible = False: MsgBox "没有领用信息!!!", 48, "温馨提示……": Exit Sub
With ListBox1
.Visible = True
.Left = ActiveCell.Left - 300
.Top = ActiveCell.Top + 30
.List = br
End With
Else
ListBox1.Visible = False
End If
End Sub
|
|