Home > Enterprise >  how to add range value to link in vba
how to add range value to link in vba

Time:06-18

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

CodePudding user response:

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.

  • Related