hyperlink to other sheets in the workbook using vba

P

pimar

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top