|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim ar, i&, rng As Range, vTemp, selRng As Range
Set rng = Range("D3", Cells(Rows.Count, "D").End(xlUp))
If Intersect(ActiveCell, rng) Is Nothing Then Exit Sub
With rng
ar = .Value: vTemp = ActiveCell.Value
For i = 1 To UBound(ar)
If ar(i, 1) = vTemp Then
If selRng Is Nothing Then
Set selRng = .Cells(i, 1).Offset(, 2)
Else
Set selRng = Union(selRng, .Cells(i, 1).Offset(, 2))
End If
End If
Next i
End With
If Not selRng Is Nothing Then selRng.Select
End Sub
|
|