简体   繁体   中英

Adding Hyperlink with Excel VBA

I am trying to add a hyperlink to an excel cell like this but getting an error:

rng.Formula = "=HYPERLINK(cell.Offset(0, 3).Value,"">"")"

Basically the hyperlink is located within another cell and i want to have the text ">" appear in the new hyperlink cell.

You are missing some double quotes:

Sub dural()
    Dim rng As Range, cell As Range
    Set rng = Range("A1")
    Set cell = Range("A2")

    rng.Formula = "=HYPERLINK(""" & cell.Offset(0, 3).Value & ""","">""  )"

End Sub

For example:

在此处输入图片说明

尝试使用超链接集合:

Sheet1.Hyperlinks.Add Sheet1.Range("A1"), "http://longLinkAddressHere", , , ">"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM