ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hyperlink to other sheets in the workbook using vba (https://www.excelbanter.com/excel-programming/353954-hyperlink-other-sheets-workbook-using-vba.html)

pimar[_8_]

hyperlink to other sheets in the workbook using vba
 

Hello everybody
my question is about using hyperlinks from VBA
I'd like to define a "next" and "previous" link in each worksheet of my
workbook, so that the "next" link will move on next sheet in the
workbook, while "previous" will activate the previous sheet.
Since my workbook will consist of a lot of sheets that are copies of
the same "master" sheet, my idea is to set the link info via VBA, in
the

Private Sub Worksheet_Activate() method..

In all the example I've found about using the Hyperlink, the hyperlink
is to html or email...

I've used this, but it does not work:


Private Sub Worksheet_Activate()

wsindex = ActiveSheet.Index
wsprev = Worksheets(wsindex - 1).Name
wsnext = Worksheets(wsindex + 1).Name
MsgBox (wsprev & " " & wsnext)

With ActiveSheet
Hyperlinks.Add Anchor:=.Range("A1"), _
Address:=Worksheets(wsprev), _
ScreenTip:=wsprev, _
TextToDisplay:="PREVIOUS SHEET"
End With

With ActiveSheet
Hyperlinks.Add Anchor:=.Range("b1"), _
Address:=Worksheets(wsnext), _
ScreenTip:=wsnext, _
TextToDisplay:="NEXT SHEET"
End With


What is wrong?
thanks
*pimar


--
pimar
------------------------------------------------------------------------
pimar's Profile: http://www.excelforum.com/member.php...fo&userid=5386
View this thread: http://www.excelforum.com/showthread...hreadid=515090



All times are GMT +1. The time now is 12:14 AM.

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