|
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ar, r&, i&, br(), m&, s
r = Cells(Rows.Count, "A").End(xlUp).Row
ar = Range("a6").Resize(r - 5, 2)
If Target.Count > 1 Then Exit Sub
If Target.Address <> "$G$5" Then Exit Sub
[G6].Resize(Rows.Count - 5, 2).ClearContents
With Target
For i = 1 To UBound(ar)
s = ar(i, 1)
If s <> "" Then
If .Value = s Then
m = m + 1
ReDim Preserve br(1 To 2, 1 To m)
br(1, m) = ar(i, 1)
br(2, m) = ar(i, 2)
End If
End If
Next
End With
If m = 0 Then MsgBox "未发现符合条件的数据!", , "退出": Exit Sub
[G6].Resize(m, 2) = Application.Transpose(br)
End Sub
|
|