#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hyperlink

I am having three sheets in Excel workBook. I created two hyperlinks in
Sheet1 to open the respective sheets (Sheet 1 & 2) on clicking the
hyperlink.
But the Sheet2 & 3 reamin hidden once the workbook is open and only
when hyperlink is clicked on Sheet 1 should the respective links should
work.
But the proble I am facing is that I applied the code in Sheet1 as
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

For hyperlink on Sheet1
'Sheet3.Visible = xlSheetVisible
Sheet3.Activate

End Sub

But whenever I click any of the two hyperlinks the same Sheet3 is
visible.

How to make visible different sheets when respective hyperlink is there
and clicked on the same sheet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hyperlink

Sonali,

You need to determine which sheet the hyperlink will follow - this can be
determined from the target's address, though you need to use just the first
part of it (e.g. get "Sheet1" from "Sheet1!A1"). Try something like:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim aSheet As String
Dim pos As Integer

aSheet = Target.SubAddress
' find the position of the '!' in the address
pos = InStr(1, aSheet, "!", vbTextCompare)
aSheet = Left(aSheet, pos - 1)

Sheets(aSheet).Visible = xlSheetVisible
Sheets(aSheet).Activate


End Sub


HTH

Tim



"Sonali" wrote in message
ups.com...
I am having three sheets in Excel workBook. I created two hyperlinks in
Sheet1 to open the respective sheets (Sheet 1 & 2) on clicking the
hyperlink.
But the Sheet2 & 3 reamin hidden once the workbook is open and only
when hyperlink is clicked on Sheet 1 should the respective links should
work.
But the proble I am facing is that I applied the code in Sheet1 as
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

For hyperlink on Sheet1
'Sheet3.Visible = xlSheetVisible
Sheet3.Activate

End Sub

But whenever I click any of the two hyperlinks the same Sheet3 is
visible.

How to make visible different sheets when respective hyperlink is there
and clicked on the same sheet



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't make hyperlink function work for hyperlink to website Frank B Denman Excel Worksheet Functions 15 February 5th 07 11:01 PM
Moving rows with Hyperlink doesn't move hyperlink address Samad Excel Discussion (Misc queries) 15 June 22nd 06 12:03 PM
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM
Macro to Copy Hyperlink to another file as a HYPERLINK, not text... dollardoc Excel Programming 1 April 7th 05 12:47 AM
reading html when hyperlink address not hyperlink text diplayed Kevin Excel Programming 1 December 4th 03 10:13 PM


All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"