我的工作表在A到Z列中有数据,在第13到49行中有超链接,它们跳转到下面行中的特定单元格。例如,行13中的超链接将跳转到行229。
在我用不同的分辨率在另一台机器上做演示之前,这些超链接都是正常的。它不是跳到第229行,而是显示第248行。
我已经对this和this进行了修补,但还没有成功。我也尝试了这个less related答案,看看我是否可以欺骗excel。我还尝试了下面的代码:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
r = ActiveCell.Row
Range(Cells(r, 1), Cells(r, 26)).Select
'Target.Range.Select
ActiveWindow.Zoom = True发布于 2015-12-03 15:41:40
如果您希望将A229放在可见工作表区域的左上角,那么可以通过先跳过您想要的工作表的可见部分并返回到它来欺骗Excel。
在A13中,放置一个指向A1229而不是A229的超链接。
Sub setup_Hyperlinks()
With Worksheets("Sheet1")
With .Range("A13")
.Hyperlinks.Delete
.Hyperlinks.Add Anchor:=.Cells(1), Address:="", SubAddress:="Sheet1!A1229", _
ScreenTip:="Jump to row 229", TextToDisplay:="Row 229"
End With
End With
End Sub请注意,实际子地址目标是A1229,而不是A229。
右击工作表的“名称”选项卡,然后选择“”“查看代码”。当VBE打开时,将以下代码之一粘贴到标题为 Book1 - Sheet1 ()的工作表代码表中。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells(1, 1).Row > 1000 Then 'this will depend on how you craft the method for your own purposes
Application.Goto _
Reference:=Target.Cells(1, 1).Offset(-1000, 0)
'[optional] move one row down for personal aesthetics
'ActiveWindow.SmallScroll Down:=-1
End If
End Sub..。或,
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If ActiveCell.Row > 1000 Then 'this will depend on how you craft the method for your own purposes
Application.Goto _
Reference:=ActiveCell.Offset(-1000, 0)
'[optional] move one row down for personal aesthetics
'ActiveWindow.SmallScroll Down:=-1
End If
End Sub使用其中之一,但不能两个都使用。前者在我的系统上的屏幕“闪光灯”似乎稍微少了一点。
发布于 2015-12-06 02:54:53
我突然想到了。查看Windows(1).VisibleRange.Rows.count
您可以看到显示了多少行,向下,这样链接目标将在顶部。无论分辨率如何,这都应该是准确的。
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim iActive As Integer
Dim lBottom As Long
Dim ws As Excel.Worksheet
Set ws = ActiveWorkbook.Sheets("Sheet1")
'Get the number of rows showing
iActive = Windows(1).VisibleRange.Rows.count
'Move to center of the active window
lBottom = ActiveCell.Row + (iActive / 2) - 1
ws.Range("A" & lBottom).Activate
End Subhttps://stackoverflow.com/questions/34055315
复制相似问题