Created
August 13, 2018 13:54
-
-
Save ghanique/2a3e0a8a3433bab1d5b2e3445270d60c to your computer and use it in GitHub Desktop.
VBA Macro for following selected Hyperlinks in Excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub OpenSelectedHyperlinks() | |
On Error GoTo ErrorHandler | |
Dim Cell As Object | |
For Each Cell In Selection | |
DoEvents | |
Call OpenHyperlink(Cell) | |
Next Cell | |
GoSub Finally | |
Exit Sub | |
Finally: | |
Return | |
ErrorHandler: | |
Debug.Print Err.Number; Err.Description | |
Stop | |
End Sub | |
Public Sub OpenHyperlink(ByVal Cell As Range) | |
On Error GoTo ErrorHandler | |
Dim link As String: Let link = Cell.Value2 | |
Call ActiveWorkbook.FollowHyperlink(link) | |
GoSub Finally | |
Exit Sub | |
Finally: | |
Return | |
ErrorHandler: | |
Debug.Print Err.Number; Err.Description | |
Stop | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment