View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Unhide multiple worksheets

Here is some example code for you to try...

Sub test()
Call UnHideSheets("2007", 3) 'matching 2007 as the 3rd part of the name
End Sub

Public Sub UnHideSheets(ByVal strToMatch As String, ByVal lngElement As Long)
Dim wks As Worksheet
Dim strName() As String

For Each wks In Worksheets
strName = Split(wks.Name, " ")
If UBound(strName) = 2 Then
wks.Visible = xlSheetHidden
If strToMatch = strName(lngElement - 1) Then wks.Visible =
xlSheetVisible
End If
Next wks
End Sub
--
HTH...

Jim Thomlinson


"mrsviqt" wrote:

I have a file that contains 144 sheets. Thyey are all named as follows
:"storenumber department year" (example: 111 abc 2007). Each store number
has 6 sheets (2 departments and three different years). What I would like is
to have a sheet named "Main" that is always unhidden. I would like to have a
spot on that sheet that asks "Which store would you like to view", "Which
department would you like to view", or "Which year would you like to view".
It will unhide the sheets based on the selection that is made. For example,
if store 111 is chosen, all of store 111's 6 sheets will be unhidden. Is
this even possible?
Thanks in advance.