Assigning a Hyperlink to A Cell that References a Worksheet

M

Max

I'd like to programatically apply a hyperlink to an active cell that will
point to a named range on another sheet in the same workbook. I haven't had
any luck with the following code:

********
Set sh = Worksheets("Dashboard")
sh.Activate
sh.Cells(p + 5, 2).Value = arrENGINE(i)
sh.Cells(p + 5, 2).Select

sh.Cells(p + 5, 2).Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=arrENGINE(i) _
, TextToDisplay:=Selection.Value
*******

where arrENGINE(i) is a string - example "GF44-123PL_G01"

Any suggestions as to what is going on?
 
D

Dave Peterson

First, that doesn't look like a valid name to me. I'd replace that hyphen with
an underscore.

and then maybe...

With sh
.Hyperlinks.Add Anchor:=.Cells(p + 5, 2), _
Address:="", _
SubAddress:=arrENGINE(i), _
TextToDisplay:=.Cells(p + 5, 2).Value
end with

(untested)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top