Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default unhide sheets

Hi all,
Is it possible to have a list of sheet names in C8:C17 on sheet "Main", and
have a macro that will UNHIDE those sheets that are listed in that range?
Essentially, I want to have all my sheets hidden until they are listed in
that range, then UNHIDE upon running the macro.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default unhide sheets

Sure, there are a couple of ways. You could put the list of names into an
Array and loop through all your worksheets to Match their names against the
Array List. Or you could do a double loop by looping through each list name
and comparing it to all the sheet names by looping through them. Or you
could just loop through the worksheets and compare their names with a Match
to the range on sheet "Main".

Mike F
"Tom" wrote in message
...
Hi all,
Is it possible to have a list of sheet names in C8:C17 on sheet "Main",
and
have a macro that will UNHIDE those sheets that are listed in that range?
Essentially, I want to have all my sheets hidden until they are listed in
that range, then UNHIDE upon running the macro.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default unhide sheets

You can't have all your sheets hidden, at least one must be visible. If Main
was always visible, you could always use even t code, like so

Option Explicit

Private Const WS_RANGE As String = "C8:C17" '<=== change to suit
Private prevVal As String

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = "" Then
If prevVal < "" Then
Worksheets(prevVal).Visible = True
End If
Else
Worksheets(.Value).Visible = False
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
prevVal = Target.Value
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tom" wrote in message
...
Hi all,
Is it possible to have a list of sheet names in C8:C17 on sheet "Main",

and
have a macro that will UNHIDE those sheets that are listed in that range?
Essentially, I want to have all my sheets hidden until they are listed in
that range, then UNHIDE upon running the macro.

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default unhide sheets

I guess I should have said that my MAIN sheet would always be visible - all
others would be hidden. Thanks for the code Bob, I'll give it a try!

"Bob Phillips" wrote:

You can't have all your sheets hidden, at least one must be visible. If Main
was always visible, you could always use even t code, like so

Option Explicit

Private Const WS_RANGE As String = "C8:C17" '<=== change to suit
Private prevVal As String

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = "" Then
If prevVal < "" Then
Worksheets(prevVal).Visible = True
End If
Else
Worksheets(.Value).Visible = False
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
prevVal = Target.Value
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tom" wrote in message
...
Hi all,
Is it possible to have a list of sheet names in C8:C17 on sheet "Main",

and
have a macro that will UNHIDE those sheets that are listed in that range?
Essentially, I want to have all my sheets hidden until they are listed in
that range, then UNHIDE upon running the macro.

Thanks!




  #5   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default unhide sheets

Hi Bob,
This code works...however, I have to DELETE the contents of the cells
(C8:C17) before the sheets become visible. Is there a way around that? I
would like the list to remain intact and not delete the list until I need to
so a VLOOKUP formula that I have linked to those cells can work.

Thanks!
Tom

"Bob Phillips" wrote:

You can't have all your sheets hidden, at least one must be visible. If Main
was always visible, you could always use even t code, like so

Option Explicit

Private Const WS_RANGE As String = "C8:C17" '<=== change to suit
Private prevVal As String

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = "" Then
If prevVal < "" Then
Worksheets(prevVal).Visible = True
End If
Else
Worksheets(.Value).Visible = False
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
prevVal = Target.Value
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tom" wrote in message
...
Hi all,
Is it possible to have a list of sheet names in C8:C17 on sheet "Main",

and
have a macro that will UNHIDE those sheets that are listed in that range?
Essentially, I want to have all my sheets hidden until they are listed in
that range, then UNHIDE upon running the macro.

Thanks!




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
Help unhide sheets sdubose99[_2_] Excel Programming 10 April 15th 06 06:07 PM
Unhide sheets Brian Matlack[_24_] Excel Programming 1 November 10th 05 07:45 PM
How to Unhide sheets pwermuth Excel Discussion (Misc queries) 4 July 15th 05 11:43 PM
Add sheets that are unhide Ron de Bruin Excel Programming 0 September 17th 03 10:50 PM
Add sheets that are unhide Bob Phillips[_5_] Excel Programming 0 September 17th 03 10:43 PM


All times are GMT +1. The time now is 05:48 AM.

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"