User defined function of hyperlink to another worksheet

  • I am writing function that creating Hyperlink to certain worksheet:
    Could you please help and replace with variables?

    Code
    Public Function HyperlinkToTab(Word As String, r As Range)
       ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="'102300117'!A1", TextToDisplay:="press"        
    '    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",  SubAddress:=" & r&" & "&r& ", TextToDisplay:=Word
    End Function


    102300117 is a name of worksheet and a same as cell "A1"

  • Re: User defined function of hyperlink to another worksheet


    Quote from jonny;595822

    I am writing function that creating Hyperlink to certain worksheet:
    Could you please help and replace with variables?


    Why do you use hyperlink of Excel, Do you do HyperlinktoTab? It not good by hyperlink of Excel
    Try


    Code
    Public Function HyperlinkToTab(Word As String, r As Range) As String
    ActiveSheet.Hyperlinks.Add Range("A1"), "", r.Value, Word
    End Function
    Sub test()
    HyperlinkToTab Range("A1"), Range("A1")
    End Sub
  • Re: User defined function of hyperlink to another worksheet


    It doesn't do what I need,
    I will try to elaborate:
    1. In column "A" I have cars models: "A1" = Toyota , "A2" = Honda, ...
    2. Also I have worksheets with same names: Toyota, Honda, ...
    What I need is to run function , will take me to Toyota worksheet, by pressing cell "B1" (or to Honda worksheet, by pressing cell "B2")

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!