Opening a hyperlink from VBA, however there is a caveat

Moonbeam111

Board Regular
Joined
Sep 24, 2018
Messages
64
Office Version
  1. 365
  2. 2010
Please excuse me but I'm stuck in a complicated spot.

So I'm trying to open a hyperlink through vba so I do not have to manually click it everytime. It' in Range("J133"). The traditional answer to this is probably
VBA Code:
Range("J133").Hyperlinks(1).Follow.

Well my problem is that the hyperlink in cell J133 is actually a reference to another hyperlink in H130. The actual formula for my cell in J33 is this.

Excel Formula:
=HYPERLINK(SUBSTITUTE(H130,"example text",H133),H133 & " " & "example text")

I needed to use this formula to substitute a portion of the name from the referenced hyperlink to use the cell text values from range "H133" instead.
The traditional answer keeps giving me a subscript out of range. I tried this as well:

VBA Code:
Sub Hyperlink()
Shell "C:\Program Files\Mozilla Firefox\firefox.exe\" & Range("J133").Text
End Sub

And get a 'file not found error'.

Is it possible I can open this hyperlink through VBA still? Even though I changed part of the name using the substitute function in excel? It's not that big of a deal ( if I click the link manually it works just fine) just trying to save time. Any help would be appreciated.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Since you know where the original Hyperlink is located, can't you just reference that in your VBA code?
 
Upvote 0
Thank you for the input. I resolved this issue since posting this thread.
Since you know where the original Hyperlink is located, can't you just reference that in your VBA code?
Indeed. That is what I did.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

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