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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using macros to create hyperlink?

Status
Not open for further replies.

fiel

Programmer
Jun 3, 2007
96
US
Is there a way in VBA to create a hyperlink to a refrence of cells?
 
I tried recording a macro and rewriting it to change the location of what I want to link to and have the following, although nothing seems to happen:

Range("ActiveCell").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"At 60!I1", TextToDisplay:="1/0"
Range("ActiveCell").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
 
recorded this:

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= "Sheet1!K72", TextToDisplay:="hypertest"

You need to ensure you change the Link Tooption on the insert hyperlink wizard to Place in this document

The only thing wrong with your code that I can see is that the sheet name is not referneced properly:

SubAddress:= "At 60!I1"

Should be:

SubAddress:="'At 60'!I1",

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top