In this article, I’ll show you how you can get the hyperlink from an Excel cell with VBA. You’ll learn to get the hyperlink from a single cell, as well as from a range of cells or the whole worksheet.
Get Hyperlink from an Excel Cell with VBA (Quick View)
Sub Get_Hyperlink_from_Whole_Worksheet()
Set Rng = ActiveSheet.UsedRange
Links = ""
For i = 1 To Rng.Hyperlinks.Count
Links = Links + vbNewLine + vbNewLine + Rng.Hyperlinks(i).Address
Next i
MsgBox Links
End Sub

How to Get Hyperlink from an Excel Cell with VBA
Here we’ve got a worksheet that contains some hyperlinks to a range of categories.

Our objective today is to get the hyperlinks from the Excel cells with VBA.
1. Get Hyperlink from a Single Cell with Excel VBA
First of all, we’ll learn to get the hyperlink from a single cell. For example, let’s try to extract the hyperlink from cell C3 of the worksheet.
The VBA code will be:
⧭ VBA Code:
Sub Get_Hyperlink_from_Single_Cell()
Cell = "C3"
Link = Range(Cell).Hyperlinks(1).Address
MsgBox Link
End Sub

⧭ Output:
Run the code. It’ll display the hyperlink from cell C3 of the active worksheet.

Read More: VBA to Add Hyperlink to Cell Value in Excel
2. Get Hyperlink from a Range of Cells with Excel VBA
We’ve learned to get the hyperlink from a single cell with Excel VBA. This time we’ll get the hyperlinks from a range of cells.
For example, let’s try to get all the hyperlinks from the range B2:C6 of the active worksheet.
The VBA code will be:
⧭ VBA Code:
Sub Get_Hyperlink_from_a_Range_of_Cells()
Set Rng = Range("B2:C16")
Links = ""
For i = 1 To Rng.Hyperlinks.Count
Links = Links + vbNewLine + vbNewLine + Rng.Hyperlinks(i).Address
Next i
MsgBox Links
End Sub

⧭ Output:
Run the code. It’ll display all the hyperlinks from the range B2:C6 of the active worksheet.

Read More: Excel VBA: Add Hyperlink to Cell in Another Sheet
3. Get Hyperlink from the Whole Worksheet with Excel VBA
Finally, we’ll learn to extract hyperlinks from the whole worksheet. The VBA code will be:
⧭ VBA Code:
Sub Get_Hyperlink_from_Whole_Worksheet()
Set Rng = ActiveSheet.UsedRange
Links = ""
For i = 1 To Rng.Hyperlinks.Count
Links = Links + vbNewLine + vbNewLine + Rng.Hyperlinks(i).Address
Next i
MsgBox Links
End Sub

⧭ Output:
Run the code. It’ll display the hyperlinks from the whole active worksheet.

Read More: Excel VBA: Open Hyperlink in Chrome
Things to Remember
In this article, I’ve focused on getting the hyperlinks from an Excel worksheet only. If you want to know details about the properties and methods of hyperlinks in Excel VBA, you can visit this article.
Download Practice Workbook
Conclusion
So these are the ways to get the hyperlinks from an Excel cell or a range of cells with VBA in Excel. Do you have any questions? Feel free to ask us.
Get FREE Advanced Excel Exercises with Solutions!

