Hyperlinks Cease to Function

Davidph

New Member
Joined
May 21, 2009
Messages
3
I've always managed to find a solution to my Excel problems on this forum but have found nothing that seems to match the problem I am experiencing with Hyperlinks so just I've registered to raise the problem and see if anyone else has seen it and or has a resolution.

I'll try and describe what has been set up and what I am seeing: -

Worksheet A has Hyperlinks from cells to Worksheet B. The are not set using =HYPERLINK(..... A FollowHyperlink procedure on Sheet A carries the content of the clicked cell to Worksheet B. Note the FollowHyperlink is only activated when a cell within a designated Range for all the Hyperlinks is clicked.

The above works absolutely fine, Sheet B has Hyperlinks to Sheet C and there is another 'FollowHyperlink' procedure on Sheet B to carry content to Sheet C.

All works fine when you reselect Sheet A or Sheet B by Sheet Tab and choose another Hyperlink.

However, in trying to be neat and easier for users to use, I added a 'Go Back' Hyperlink (this is outside the Range of 'working' Hyperlinks on the sheet) on Sheet B that simply jumps back to Sheet A and a similar one of Sheet C that goes back to Sheet B.

As soon as I use one, or other, of the 'Go Back' Hyperlinks all the other hyperlinks no longer initiate the 'FollowHyperlink' procedure when clicked. They still move to the destination sheet but there is no further change in data as would happen if the 'FollowHyperlink' procedure had been actioned.

If I close Excel completely at this point and re-open the file the Hyperlinks work properly, with manual switching of worksheets and then fail as soon as I use the 'Go Back' hyperlinks.

I'd be very grateful if someone has a solution to this problem.

Regards,

Davidph
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Immediately after using a GoBack hyperlink, if you open the VBE, go to the Immediate window and type:
Code:
?Application.Enableevents
and press Enter, does it return False?
 
Upvote 0
Hi royra, thank you for the quick response.

Yes the suggestion you made below returns FALSE.

Regards,

Davidph
 
Upvote 0
What is the code in your followhyperlink event - there seems to be a flaw in it that is disabling events.
 
Upvote 0
Hi royra, I think I've sussed it thanks to your question.

The FollowHyperlink procedure has an Application.EnableEvents = False as the first call but the Application.EnableEvents = True, to reset, was in the If.....End If call that checks which Hyperlinks were being clicked so wouldn't have been called when the 'Go Back' hyperlink was clicked. EnableEvents was stuck as False. My useless coding!!

Having added a Application.EnableEvents = True directly before the End Sub seems to have sorted it.

Thanks for pointing me in the right direction.

Regards,

David
 
Upvote 0
I suspected as much! As a rule, if you disable events in your code, it's a good idea to ensure that there is only one exit point from your code and that it re-enables events. For example:
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
   On Error GoTo err_handle
   Application.EnableEvents = False
   
   ' rest of code here
   ' do NOT use an Exit Sub!
   
clean_up:
   ' reset events
   Application.EnableEvents = True
   ' then exit
   Exit Sub
err_handle:
   ' notify error
   MsgBox Err.Description
   ' make sure to reset events
   Resume clean_up
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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