Insert Hyperlink

G

Guest

I have a worksheet and I am using code to add some Hyperlinks, I am using
code to add the hyperlink but for some unknown reason it is not entering the
sub address correctly, Here is the code maybe someone could point me in the
right direction

Range("H1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="Billing!A3:A45", TextToDisplay:="Americas"
Range("I1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="Billing!A47:A89", TextToDisplay:="Asia\Pac"
Range("J1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="Billing!A91:A133", TextToDisplay:="Eur\ROW"
Range("K1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="Billing!A135:A177", TextToDisplay:="Market"
Range("L1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:="Billing!A179:A192", TextToDisplay:="Summary"

it puts A1 as the Cell Reference

Thanks

Nigel
 
D

Dave Peterson

Try:

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", _
SubAddress:="#Billing!A3:A45", TextToDisplay:="Americas"

Did you really want 43 cells selected when you click that link.
 
G

Guest

No that doesn't help, I think I read somewhere you can add a hyperlink using
code
 
D

Dave Peterson

It worked fine for me.

Did you already have a hyperlink in H1?

with activesheet.range("H1")
if .hyperlinks.count > 0 then
.hyperlinks.delete
end if
.parent.Hyperlinks.Add Anchor:=.cells, Address:="", _
SubAddress:="#Billing!A3:A45", TextToDisplay:="Americas"
end with

What happened when you tried it?

and did you notice the change? I added # in front of "billing".
 

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