satcha
satcha

Reputation: 129

how to add range value to link in vba

i would like to add range value to my link but it is doesn't work some one can help how can i add range value to the link please? thanks a lot

    Dim iLink
    Dim myUrl
    Dim Number
    
    i = 7
    Number= Range("D" & i).Value
    myUrl = "https://www.google.com/Number"

    While Range("D" & i).Value <> ""
    iLink = myUrl & Range("D" & i).Value

    ActiveSheet.Hyperlinks.Add _
    Anchor:=Range("D" & i).Offset(, 1), _
    Address:=iLink
    i = i + 1
    Wend

Upvotes: 0

Views: 197

Answers (1)

JoeStar
JoeStar

Reputation: 83

You can do it like this

myUrl = "https://www.google.com/" & Number

Because you enclosed your variable 'Number' inside double quotes, vba counted it as a string, not a variable.

Upvotes: 3

Related Questions