Insert Hyperlink

Discussion in 'Microsoft Excel Programming' started by Guest, Jan 9, 2006.

  1. Guest

    Guest 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
     
    Guest, Jan 9, 2006
    #1
    1. Advertisements

  2. 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.

    Nigel wrote:
    >
    > 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


    --

    Dave Peterson
     
    Dave Peterson, Jan 9, 2006
    #2
    1. Advertisements

  3. Guest

    Guest Guest

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

    "Dave Peterson" wrote:

    > 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.
    >
    > Nigel wrote:
    > >
    > > 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

    >
    > --
    >
    > Dave Peterson
    >
     
    Guest, Jan 9, 2006
    #3
  4. 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".

    Nigel wrote:
    >
    > No that doesn't help, I think I read somewhere you can add a hyperlink using
    > code
    >
    > "Dave Peterson" wrote:
    >
    > > 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.
    > >
    > > Nigel wrote:
    > > >
    > > > 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

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson
     
    Dave Peterson, Jan 9, 2006
    #4
  5. Guest

    Guest Guest

    I got it to work by naming the range and then it worked fine

    thanks for your help

    "Dave Peterson" wrote:

    > 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".
    >
    > Nigel wrote:
    > >
    > > No that doesn't help, I think I read somewhere you can add a hyperlink using
    > > code
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > 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.
    > > >
    > > > Nigel wrote:
    > > > >
    > > > > 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
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >
     
    Guest, Jan 10, 2006
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dim

    hyperlink breaks if space within hyperlink

    Dim, Jul 31, 2003, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    657
    Jerry Park
    Aug 1, 2003
  2. Guest
    Replies:
    1
    Views:
    375
    Dick Kusleika
    Dec 4, 2003
  3. dollardoc

    Macro to Copy Hyperlink to another file as a HYPERLINK, not text...

    dollardoc, Apr 6, 2005, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    583
    Robin Hammond
    Apr 7, 2005
  4. Guest
    Replies:
    5
    Views:
    273
    beatrice25
    May 17, 2006
  5. Guest

    Hyperlink to Hyperlink

    Guest, Nov 9, 2006, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    151
    Guest
    Nov 9, 2006
Loading...

Share This Page