VBA Hyperlink Debugging

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
152
Hey everyone. I am currently working on Debugging a code that has worked wonders for me for the last 10 years. Here is my code:

1 Worksheets(1).Select
2 R = Range("A65536").End(xlUp).Row
3 For Each Cell In Range("A2:A" & R)
4 Cell.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=False
5 Next Cell
6 CopyTargetBookmark = 1
7 For Each Workbook In Application.Workbooks

It is getting hung up on line 4 with a run-time error 9 "Subscript is out of range". ANY input would be invaluable.

Thank you,
Peter
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try changing the Follow line to:
Code:
        If Cell.Hyperlinks.Count > 0 Then Cell.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=False
 
Upvote 0
You are a gentleman and a scholar. Worked like a charm. Never thought to try an If Then structure.
 
Upvote 0
So I have found what has been causing my problem.

What this code does:
It takes information from LOTS of workbooks, and concatenates the useful information into 1 workbook (it is much longer than shown above).

The Problem:
Either via a bug or deliberate implementation, Microsoft has decided the "Cell.Hyperlinks(1).Follow" function should not work for code generated hyperlinks. It does work for manually generated hyperlinks. It even works if I decide to use F8 and step through my code "manually".

The Question:
Is there a work around or subroutine anyone knows of or has written that circumvents the problem? I.E. Is there a way to automatically open code generated hyperlinks other than the "Cell.Hyperlinks(1).Follow" function?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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