PaulAsaran
New Member
- Joined
- Feb 11, 2019
- Messages
- 22
This is a followup question of a previous query I posted. In that thread, I was looking for a way to have Excel automatically scroll so that the hyperlink's target cell would appear in the top-left corner of the screen. Fluff was kind enough to provide the following solution (thanks again!):
This works fine for one worksheet. The problem I've found is that my file contains numerous spreadsheets full of tables (it's a data-intensive doc). I can put the code in the worksheets that have hyperlinks, but it appears the code only works if the hyperlink targets cells that are in the same worksheet as the link. Some of my hyperlinks go to other worksheets within the file. When I try to use those, I get the following error:
The hyperlink still works, it's just not scrolling. How can I alter this code so that it works for hyperlink targets both in and outside of the currently active worksheet?
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Application.Goto Range(Target.SubAddress), True
End Sub
This works fine for one worksheet. The problem I've found is that my file contains numerous spreadsheets full of tables (it's a data-intensive doc). I can put the code in the worksheets that have hyperlinks, but it appears the code only works if the hyperlink targets cells that are in the same worksheet as the link. Some of my hyperlinks go to other worksheets within the file. When I try to use those, I get the following error:
Run-time error '1004': Method 'Range' of object '_Worksheet' fail
The hyperlink still works, it's just not scrolling. How can I alter this code so that it works for hyperlink targets both in and outside of the currently active worksheet?