How to Click Hyperlink in Excel with VBA Macro?
There are 2 methods available to click a hyperlink in Excel.
Both the methods do open the URL in the default browser or open the corresponding file in the default application.
Here is the code demonstrates both methods.
Sub follow_hyperlink() 'Follow Hyperlink Examples - Officetricks Dim ihyperLink As Hyperlink Dim wSh As Worksheet Set wSh = ThisWorkbook.Sheets(1) 'Method 1: Follow using a URL ThisWorkbook.FollowHyperlink "https://officetricks.com" 'Mehod 2: Follow using HYperlink in Cell For Each ihyperLink In wSh.Hyperlinks ihyperLink.Follow Next End Sub
The first methods uses the workbook objects .FollowHyperlink function. It takes the url as parameter.
Whereas in the second method, the code loops thru all the hyperlinks present in the worksheet. Opens the hyperlink on by one using the Hyperlink objects .Follow function.
Both the function have few more parameters.
In one of that, You can also specify whether the Hyperlink should be opened as new window or as a tab in existing Browser application.