PDA

View Full Version : How to unhide the hiden sheet



waseem.aman
02-28-2011, 08:12 AM
hi guys i am using the below code which open the hide sheet

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim WB As Workbook
Dim WSName As String
Dim WS As Worksheet
Dim N As Long
With Target
If .Address = vbNullString Then
Set WB = ThisWorkbook
Else
Set WB = Workbooks(.Address)
End If

N = InStr(1, .SubAddress, "!")
WSName = Replace(Left(.SubAddress, N - 1), "'", vbNullString)
Set WS = WB.Worksheets(WSName)
If WS.Visible <> xlSheetVisible Then
Application.EnableEvents = False
WS.Visible = xlSheetVisible
Target.Follow
Application.EnableEvents = True
End If
End With
End Sub


Once the sheet open i want to go back to main sheet and the open sheet shouls hide agian for that i am using code below[/COLOR]


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Worksheets(Left(Target.SubAddress, InStr(1, Target.SubAddress, "!") - 1)).Visible = xlSheetVisible
Application.EnableEvents = False
Target.Follow Application.EnableEvents = True
End Sub

Hide Worksheet Automatically
Private Sub Worksheet_Activate()Me.Visible = xlSheetVisible
End Sub Private Sub

Worksheet_Deactivate()
Me.Visible = xlSheetVeryHidden
End Sub


Its hiding the the sheet permanently i am unable to unhide the sheet manualy can you please anybody help to regain the sheet which got hide..

Unhide is disable if we click and try tu unhide

Bob Phillips
02-28-2011, 08:54 AM
Worksheet_Deactivate()
Me.Visible = xlSheetHidden
End Sub

draco664
02-28-2011, 06:24 PM
Worksheet_Deactivate()
Me.Visible = xlSheetVeryHidden
End Sub[/vba]


Its hiding the the sheet permanently i am unable to unhide the sheet manualy can you please anybody help to regain the sheet which got hide..

Unhide is disable if we click and try tu unhide

xlSheetVeryHidden is designed to hide the sheet in such a way that it can't be unhidden from within excel.

You should use xlSheetHidden instead.

Chris