Excel Hyperlink - jump to cell and scroll window

…衆ロ難τιáo~ 提交于 2020-01-10 20:06:29

问题


I am working in excel and I want to make a Hyper Link from the top of the page to another location on the page.

I type in a box at the top, and then right link and go down to hyper link in the dropdown menu I click it and select the tab that says "In This Work Book" and change it to where I want it to go. So all this is good and all but my Question is:

Can I make a Hyper link to bring me to a cell and scroll the window so the selected cell is the first row, instead of being near the bottom of the window?

Example:

Hyper link: "Test" Located in Cell A,1

Location Of Hyper Link: A,210

Now instead of having it put A,210 at the very Bottom and show the cells above it, I want to to be at the top and show the cells below it.

Thanks for the help,


回答1:


Add the following VBA code to your worksheet:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    ActiveWindow.ScrollRow = ActiveCell.Row
End Sub

By magic, when you click a link, that cell will be at the top. If you don't want this behavior for all links, you can test the Target address.

You will have to save the code as a xlsm file so that macros are enabled. Use Alt-F-11 to open the VBA editor so you can actually add the code (double click the worksheet in the left hand pane, then paste the above code in the window that opens).



来源:https://stackoverflow.com/questions/19127549/excel-hyperlink-jump-to-cell-and-scroll-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!