Activating URL links in a range of cells

asad

Well-known Member
Joined
Sep 9, 2008
Messages
1,434
Hello All,

Hope someone here will be able to tell me how to activate URL link in a range of cells using VBA.
I tried to record the macro, but all it gives me is
Code:
Sub Macro3()'
' Macro3 Macro
'


'
    Range("N10").Select
    ActiveCell.FormulaR1C1 = _
        "https://****.com.au/****/***/template/generic/******/"
    Range("N45").Select
End Sub

Sorry I had to replace the words with * as it is live and sensitive information. And each cell will have a different link.

I tried
Code:
Sub Test()For Each Cell In Range("N49:N50")
Cell.FormulaR1C1 "=" & Cell.Value
Next
End Sub
And also
Code:
Sub Test()For Each Cell In Range("N49:N50")
Cell.Select
ActiveCell.FormulaR1C1 "=" & Cell.Value
Next
End Sub

Nothing works so far.
Please let me know how to do this.
Thanks for your help.

Asad
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Like this:

Code:
Sub URL()
Worksheets("Sheet1").Hyperlinks.Add Range("N10"), "http://www.google.com", , , "Google"
End Sub

or if you just want the actual URL to show and not a custom Text to Display:
Code:
Sub URL()
Worksheets("Sheet1").Hyperlinks.Add Range("N10"), "http://google.com"
End Sub
 
Last edited:
Upvote 0
Like this:

Code:
Sub URL()
Worksheets("Sheet1").Hyperlinks.Add Range("N10"), "http://www.google.com", , , "Google"
End Sub

Thanks Scott,

Will that apply to the whole range like this:
Code:
Sub Test()
For Each Cell In Range("N49:N50")
Worksheets("Data").Hyperlinks.Add Cell, "http://www.google.com", , , "Google"
Next
End Sub
 
Last edited:
Upvote 0
If I understand the second part of your question, you have URLS in the cells as text. If that's the case, then perhaps this will do what you want.

Code:
Sub MakeURL()
Dim x As Long
For x = 49 To 50
    Worksheets("Sheet1").Hyperlinks.Add Range("N" & x), Range("N" & x)
Next
End Sub
 
Last edited:
Upvote 0
I also tried this:
Code:
Sub Test()For Each Cell In Range("N49:N50")
[COLOR=#ff0000]Worksheets("Data").Hyperlinks.Add Cell, "http://www.google.com[/COLOR]"
Next
End Sub
But no luck. It highlights the line shown in red above.
 
Upvote 0
If I understand the second part of your question, you have URLS in the cells as text. If that's the case, then perhaps this will do what you want.

Code:
Sub MakeURL()
Dim x As Long
For x = 49 To 50
    [COLOR=#ff0000]Worksheets("Sheet1").Hyperlinks.Add Range("N" & x), Range("N" & x)[/COLOR]
Next
End Sub
Same problem with this one as well. The line in red above gets highlighted.
 
Upvote 0
Sorry, my bad.

I forgot to change the sheet name.
It does work perfect.

Thanks a lot.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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