Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert a hyperlink in sheet? 1

Status
Not open for further replies.

JensKKK

Technical User
May 8, 2007
119
GB
I am frequently using the =hyperlink() function in workbooks.

Now I want to insert a hyperlink with VBA in my workbook.

This is the code I tried to use, but the compiler stops in line 4. Any ideas how to insert a hyperlink into a workbook with VBA

Many thanks

part1 = "part2 = "google"
part3 = "=hyperlink(" & part1 & "," & part2 & ")"
msg = MsgBox("msg: " & part3)
Sheets("detailed results").Cells(5 + i + j, 2) = part3
 
if you record a macro, this is what you will have:
Code:
    Range("A1").Select
    ActiveSheet.Hyperlinks.Add _
        Anchor:=Selection, Address:= _
        [blue]"[URL unfurl="true"]http://www.google.com"[/URL][/blue], TextToDisplay:=[blue]"My google"[/blue]

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top