ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   add hyperlink using sheet names and cells(i,j) (https://www.excelbanter.com/excel-worksheet-functions/449663-add-hyperlink-using-sheet-names-cells-i-j.html)

tuli

add hyperlink using sheet names and cells(i,j)
 
Hello,

I have these two routines. They are supposed to do the same. For some reason, the Y routine gives me an error.
Please advise

Thank you
Tuli


Public Sub X()
Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _
"'sheet2'!A1", TextToDisplay:="Back <<"
End Sub

Public Sub Y()

Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _
Sheets("sheet2").Cells(2, 1), TextToDisplay:="Back <<"
End Sub

Claus Busch

add hyperlink using sheet names and cells(i,j)
 
Hi,

Am Tue, 31 Dec 2013 12:30:17 -0800 (PST) schrieb tuli:

Public Sub X()
Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _
"'sheet2'!A1", TextToDisplay:="Back <<"
End Sub

Public Sub Y()

Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _
Sheets("sheet2").Cells(2, 1), TextToDisplay:="Back <<"
End Sub


Address and Subaddress have to be strings and not objects.


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

tuli

add hyperlink using sheet names and cells(i,j)
 
thanks,

Any ideas on how do do it?


On Tuesday, December 31, 2013 3:30:17 PM UTC-5, tuli wrote:
Hello,



I have these two routines. They are supposed to do the same. For some reason, the Y routine gives me an error.

Please advise



Thank you

Tuli





Public Sub X()

Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _

"'sheet2'!A1", TextToDisplay:="Back <<"

End Sub



Public Sub Y()



Sheets("Sheet1").Hyperlinks.Add Anchor:=Sheets("sheet1").Cells(1, 2), Address:="", SubAddress:= _

Sheets("sheet2").Cells(2, 1), TextToDisplay:="Back <<"

End Sub



Claus Busch

add hyperlink using sheet names and cells(i,j)
 
Hi,

Am Tue, 31 Dec 2013 13:11:31 -0800 (PST) schrieb tuli:

Any ideas on how do do it?


the way you did it in macro "X" is the best way to do it.
But you can also try:
SubAddress:= "Sheet2!" & Cells(2, 1).Address(0,0)


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com