2015-12-02 73 views
3

我的工作表具有列A到Z中的数据。我在第13到49行中有超级链接,它们跳到下面行中的特定单元格。例如,第13行的超链接将跳转到第229行。根据分辨率通过FollowHyperlink事件调整缩放比例

超链接没有问题,直到我在另一台具有不同分辨率的计算机上进行演示文稿为止。它不是跳到第229行,它显示第248行。

我修了thisthis,但没有成功。也试过这个less related的答案,看看我是否可以狡猾擅长。我也曾尝试下面的代码:

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 
+0

你可以使链接大火,找到您根据链接点击想要的数据的功能,然后做一个范围(“A”&行).Activate – MatthewD

回答

2

如果您正在寻找把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(Code)

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 

使用一个或另一个但不是两者。前者似乎在我的系统上的屏幕“闪光”稍微少一些。

+0

Jeeped和@matthewD没有时间之前演示文稿解决它,但谢谢。下次可能会派上用场。 – findwindow

1

它只是打我。退房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 Sub 
+0

我没有正确解释我的问题,但你明白了。它需要它到行,但我不希望它在底部,但在顶部,所以我计算了多少行我需要使它发生在我的电脑上运行良好,直到我去了另一个更大的屏幕。现在无法进入大屏幕来真正测试:/我将在下次再次访问我的另一个演示文稿,谢谢<3 – findwindow

+0

我明白你的意思,它只是打我看看可见范围。退房编辑回答.. – MatthewD

+0

哦,男人,这看起来很有前途! – findwindow