Variable in path of the hyperlink

ilopez

New Member
Joined
Apr 11, 2016
Messages
2
Hi ! Greetings from Paris :) !
I've just started playing with VBA, macros, and all this stuff on excel.

I've created this macro:

Sub MiPrimeraMacro()
With Worksheets(1)
.Hyperlinks.Add Anchor:=.Range("i2"), _
Address:=("http://www.apple.com/" & Range("i2")), _
ScreenTip:="Apple link"
End With
End Sub

What I've done is that the last part of the hyperlink it's read from the cell itself (in this case: mac, music, iphone, etc).
What I want know is to do the same in each cell of the column, and I'd like to know if there's a faster option rather than copying and pasting each time the sub and change the cell number.

Thank you very much for your help!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Welcome to the Forum!

You could try something like this:

Code:
Sub MiPrimeraMacro()
Dim c As Range
With Worksheets(1)
    For Each c In .Range("I2:I" & .Range("I" & .Rows.Count).End(xlUp).Row)
        .Hyperlinks.Add Anchor:=c, Address:="http://www.apple.com/" & c.Value, ScreenTip:="Apple Link"
    Next c
End With
End Sub
 
Upvote 0
Thank you very very much, I've tried it and it works great!

Welcome to the Forum!

You could try something like this:

Code:
Sub MiPrimeraMacro()
Dim c As Range
With Worksheets(1)
    For Each c In .Range("I2:I" & .Range("I" & .Rows.Count).End(xlUp).Row)
        .Hyperlinks.Add Anchor:=c, Address:="http://www.apple.com/" & c.Value, ScreenTip:="Apple Link"
    Next c
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,777
Members
449,336
Latest member
p17tootie

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