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

Creating a hyperlink to a sheet

Status
Not open for further replies.

davedave24

Programmer
Aug 26, 2010
113
GB
Hi, I have a button on multiple pages that I need to place a hyperlink back to the page it came from. The hyperlink will be placed on the first worksheet, called Overview.

Code:
Dim TargetSheet As Worksheet
[highlight #73D216]I've tried both of these and other things but none work[/highlight]
[COLOR=#4E9A06]Set TargetSheet = ActiveSheet.Name[/color]
[COLOR=#4E9A06]Set TargetSheet = ActiveSheet.Range("C2")[/color]   'C2 also contains the name of the sheet


 With ThisWorkbook.Worksheets("Overview")
        .Select
        .Range("B4").Select
        Selection.End(xlDown).Offset(1, 0).Select

        [COLOR=#EF2929]ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=TargetSheet[/color]       

End with
 
Hi,

Did you use you macro recorder?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yeah I used it to generate the 'ActiveSheet.Hyperlinks.Add ....' line
 
THAT code was NOT generated by record. You may have used PART of the recorded macro, but THAT is not recorded code!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yes, I used the macro function to generate the line, and I've altered the end of it to make the link go to the page that generated it.
 
Well then you don't need any help!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Error?

What error on what statement?

ALSO please post the exact macro code generated by the recorder.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top