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?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,814
Messages
6,181,126
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top