excel 链接到指定数据
表一
A1 A2
1 01
2 02
表二
A1 A2 A3
1 01 100
2 01 15
3 02 25
4 02 63
要求:在表一中A2列建立超链接,点击后直接定位到表二中与表一关联的数据行
[解决办法]
sheet2里加个selectionchange事件
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 2 Then Exit Sub
If Target.Row = 1 Then Exit Sub
If Len(Target.Value) = 0 Then Exit Sub
Dim findResult
Dim lRow&
Set findResult = Sheet1.Range("a:a").Find(Cells(Target.Row, 1).Value, , xlValues, xlWhole)
If findResult Is Nothing Then Exit Sub
lRow = findResult.Row
Sheet1.Activate
Sheet1.Rows(lRow).Select
End Sub
[解决办法]