Excel VBA: Add Hyperlink to Cell in Another Sheet (2 Examples)

In this article, I’ll show you how you can add a hyperlink to a cell in another sheet using VBA in Excel.


Excel VBA: Add Hyperlink to Cell in Another Sheet (Quick View)

Sub Hyperlink_with_Hyperlink_Property()

Worksheets("Sheet1").Range("D4").Hyperlinks.Add _
                                                  Anchor:=Range("D4"), _
                                                  Address:="www.exceldemy.com", _
                                                  TextToDisplay:="Site Address"

End Sub

VBA Code to Add Hyperlink to a Cell in Another Sheet with Excel VBA


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


2 Effective Examples to Add Hyperlink to Cell in Another Sheet with Excel VBA

So without further delay, let’s move to our main discussion today. You can add a hyperlink to a cell in another sheet in 2 possible ways.


1. Add Hyperlink to Cell in Another Sheet Directly with Excel VBA

First of all, you can add a hyperlink to a cell in a worksheet directly with Excel VBA.

For example, let’s add the link www.exceldemy.com” to cell B4 of the worksheet Sheet1 of the workbook. The VBA code will be:

⧭ VBA Code:

Sub Add_Hyperlink()
Worksheets("Sheet1").Range("B4") = "www.exceldemy.com"
End Sub

VBA Code to Add Hyperlink to a Cell in Another Sheet in Excel

⧭ Output:

Run this code. It’ll insert the link www.exceldemy.com” to cell B4 of the worksheet Sheet1 of the workbook.

⧭ Note:

Though this is the most simple method, it is not quite useful in practical circumstances. While working with hyperlinks, most often we need to insert the link in the disguise of another text. But we can’t accomplish this using this method.

Read More: VBA to Add Hyperlink to Cell Value in Excel (4 Criteria)


Similar Readings


2. Add Hyperlink to Cell in Another Sheet with the Hyperlinks.Add Property of Excel VBA

We found that the previous method was pretty simple, but it was not quite useful in practical situations.

Now we’ll learn the method that’s a bit complex but will come in quite handy in useful situations.

Let’s try to insert the link www.exceldemy.com” again in cell B4 of the worksheet Sheet2, in the disguise of the text “Site Address”.

We’ll use the Hyperlinks. Add method of VBA for this purpose.

The Hyperlinks. Add method takes a total of 5 arguments.

  • Anchor: The location of the hyperlink. Here it’s Worksheets(“Sheet2”).Range(“D4”).
  • Address: The hyperlink. Here it’s exceldemy.com.
  • [Sub Address]: Location of the page. Optional. We’ll not use it here.
  • [Screen Tip]: Value to be shown when a mouse pointer is placed. Optional. We’ll not use it.
  • [TextToDisplay]: The text that’ll be shown on the cell. Optional. Here it’s Site Address.

Therefore, the VBA code will be:

⧭ VBA Code:

Sub Hyperlink_with_Hyperlink_Property()

Worksheets("Sheet2").Range("D4").Hyperlinks.Add _
                                                  Anchor:=Worksheets("Sheet2").Range("D4"), _
                                                  Address:="www.exceldemy.com", _
                                                  TextToDisplay:="Site Address"

End Sub

VBA Code to Add Hyperlink to a Cell in Another Sheet with Excel VBA

⧭ Output:

Run this code. It’ll insert the link www.exceldemy.com” to cell B4 of the worksheet Sheet2 of the workbook in the disguise of the text “Site Address”.

Read More: Excel Hyperlink to Cell in Another Sheet with VLOOKUP (With Easy Steps)


Things to Remember

In this article, I’ve focused on adding a hyperlink to a cell only. If you want to know more about Excel hyperlinks, you can visit this link.


Conclusion

So these are the ways to add a hyperlink to a cell in an Excel worksheet with VBA. Do you know any other method? Feel free to ask us. And don’t forget to visit our site ExcelDemy for more posts and updates.


Related Articles

Rifat Hassan

Rifat Hassan

Hello! Welcome to my profile. Here I will be posting articles related to Microsoft Excel. I am a passionate Electrical Engineer holding a Bachelor’s degree in Electrical and Electronic Engineering from the Bangladesh University of Engineering and Technology. Besides academic studies, I always love to keep pace with the revolution in technology that the world is rushing towards day by day. I am diligent, career-oriented, and ready to cherish knowledge throughout my life.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo