Auto-Scrolling from Hyperlink in Multiple Sheets

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!):

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?
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Watch MrExcel Video

Forum statistics

Threads
1,118,140
Messages
5,570,402
Members
412,321
Latest member
Yusuf_A
Top