Hyperlink Function in VBA which works with FollowHyperlink --> "https://www.google.hu/search?q=" & "apple"

makiwara

Board Regular
Joined
Mar 8, 2018
Messages
171
Hi! I have a button with an assigned macro to it, which follows every hyperlink in the selected cells.

But I can't create a customized URL in VBA (using a new FUNCTION), because it shows an error message every time I try to follow the new url using the macro.

However, if I type the same URL manually, everything goes fine: the macro follows it and opens in a browser.
______________________________________

So shortly:

The output I need:

A1 B1 C1
h"ttps://www.google.hu/search?q= apple h"ttps://www.google.hu/search?q=apple


If this output is made manually (--> I type it), then the macro works fine.

But if I make it using a FUNCTION, the result is the same URL for the first sight, but neither my macro can open it nor me (clicking on it).

My macro (this is correct, it's 100%)

Code:
Sub Hyperlink_Follow()Dim c As Range
Dim url As String
For Each c In Selection.Cells
url = ""
On Error Resume Next
url = c.Hyperlinks(1).Address
If url = "" Then url = c.Value
ThisWorkbook.FollowHyperlink url


Next
End Sub

______________________________________

Can you help me with an URL editor Function, which creates a real clickable Hyperlink?

For example: google(String)
=google(apple) --> https://www.google.hu/search?q=apple

Thank you for your help, have a very nice day!
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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