ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to Hide/Unhide Worksheet (https://www.excelbanter.com/excel-programming/429928-code-hide-unhide-worksheet.html)

Barb Reinhardt

Code to Hide/Unhide Worksheet
 
I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt

Jacob Skaria

Code to Hide/Unhide Worksheet
 
'visible
myWS.Visible = 1
'hidden
myWS.Visible = 0
'very hidden
myWS.Visible = 2

To toggle between hide and unhide; try

myWS.Visible = not myWS.Visible

If this post helps click Yes
---------------
Jacob Skaria


"Barb Reinhardt" wrote:

I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt


Barb Reinhardt

Code to Hide/Unhide Worksheet
 
Thanks, but I already have this information. I've seen a way somewhere on
how to have a variable default to some specified options for values when the
sub is called, such that only allows Hidden, Visible and VeryHidden. That's
what I'm looking for.

"Jacob Skaria" wrote:

'visible
myWS.Visible = 1
'hidden
myWS.Visible = 0
'very hidden
myWS.Visible = 2

To toggle between hide and unhide; try

myWS.Visible = not myWS.Visible

If this post helps click Yes
---------------
Jacob Skaria


"Barb Reinhardt" wrote:

I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt


Patrick Molloy

Code to Hide/Unhide Worksheet
 
a Hidden sheet can still be seen, and possibly unhidden by the user through
the Format/Sheets/Unhide menu - hidden sheets are listed here. However
VeryHidden sheets cannot be seen in this list. they can only be seen in the
workbooks property window and listed in code.

"Barb Reinhardt" wrote in message
...
I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt



Jacob Skaria

Code to Hide/Unhide Worksheet
 
xlSheetHidden
xlSheetVeryHidden
xlSheetVisible

If this post helps click Yes
---------------
Jacob Skaria


"Barb Reinhardt" wrote:

Thanks, but I already have this information. I've seen a way somewhere on
how to have a variable default to some specified options for values when the
sub is called, such that only allows Hidden, Visible and VeryHidden. That's
what I'm looking for.

"Jacob Skaria" wrote:

'visible
myWS.Visible = 1
'hidden
myWS.Visible = 0
'very hidden
myWS.Visible = 2

To toggle between hide and unhide; try

myWS.Visible = not myWS.Visible

If this post helps click Yes
---------------
Jacob Skaria


"Barb Reinhardt" wrote:

I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt


Barb Reinhardt

Code to Hide/Unhide Worksheet
 
I understand all that. I'm still looking for code for something like this

Sub Test (myVal as variant)

where I can programmatically define several discrete options for myVal.
Only those values are allowed. I've seen it on other code, but just can't
find it. It's something that done outside of the procedure as I recall.

Barb Reinhardt

"Patrick Molloy" wrote:

a Hidden sheet can still be seen, and possibly unhidden by the user through
the Format/Sheets/Unhide menu - hidden sheets are listed here. However
VeryHidden sheets cannot be seen in this list. they can only be seen in the
workbooks property window and listed in code.

"Barb Reinhardt" wrote in message
...
I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt




Patrick Molloy

Code to Hide/Unhide Worksheet
 
i kinda guessed you did ;)

wasn;t sure what you needed though

"Barb Reinhardt" wrote in message
...
I understand all that. I'm still looking for code for something like this

Sub Test (myVal as variant)

where I can programmatically define several discrete options for myVal.
Only those values are allowed. I've seen it on other code, but just can't
find it. It's something that done outside of the procedure as I recall.

Barb Reinhardt

"Patrick Molloy" wrote:

a Hidden sheet can still be seen, and possibly unhidden by the user
through
the Format/Sheets/Unhide menu - hidden sheets are listed here. However
VeryHidden sheets cannot be seen in this list. they can only be seen in
the
workbooks property window and listed in code.

"Barb Reinhardt" wrote in
message
...
I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt




keiji kounoike

Code to Hide/Unhide Worksheet
 
This is not what you saw someone's code. but what about checking you
arguments before starting procedure like below?

Sub testcall()
test 123
End Sub

Sub test(myval As Variant)
Select Case myval
Case xlSheetHidden, xlSheetVisible, xlSheetVeryHidden
Case Else
'Msgbox is not needed, just for test
MsgBox "Wrong arg:" & myval
Exit Sub
End Select

'start your code from here
MsgBox myval

End Sub

Keiji

Barb Reinhardt wrote:
I understand all that. I'm still looking for code for something like this

Sub Test (myVal as variant)

where I can programmatically define several discrete options for myVal.
Only those values are allowed. I've seen it on other code, but just can't
find it. It's something that done outside of the procedure as I recall.

Barb Reinhardt

"Patrick Molloy" wrote:

a Hidden sheet can still be seen, and possibly unhidden by the user through
the Format/Sheets/Unhide menu - hidden sheets are listed here. However
VeryHidden sheets cannot be seen in this list. they can only be seen in the
workbooks property window and listed in code.

"Barb Reinhardt" wrote in message
...
I want to do something like this

Sub HideUnhideSheets(myWS As Excel.Worksheet, myHidden As Variant)
If myWS.Visible < myHidden Then
myWS.Visible = myHidden
End If

End Sub

What I want to do is set it up so that myHidden only allows xlVisible,
xlHidden and xlVeryHidden (or whatever they are). How do I do that?

Thanks,
Barb Reinhardt




All times are GMT +1. The time now is 01:06 AM.

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