Yep.
I would add another (hidden) sheet (or on an out of the way location on the Main
sheet).
This sheet would hold all the possible store numbers in column A.
It would hold all the department numbers in column B.
And all the possible years in column C.
Then I would name each of these lists using a dynamic range name.
Debra Dalgleish explains dynamic range names here:
http://contextures.com/xlNames01.html#Dynamic
I'd use the names: List_StoreNumber, List_Dept, List_Year
Then I'd add Data|Validation to 3 cells on the Main sheet that use these 3
lists.
http://contextures.com/xlDataVal01.html
And I'd give each of those cells a nice name (Input_StoreNumber, Input_Dept,
Input_Year).
And finally, I'd add a button from the Forms toolbar. This button would have a
macro assigned to it that would check to see if any of those cells are used. If
at least one is, then it would cycle through the worksheets looking for matches
based on the stuff that was specified.
If there are other sheets visible when the user hits the button, should those
sheets be hidden--or kept visible?
You ready to try???
Option Explicit
Sub ShowSheets()
Dim MainWks As Worksheet
Dim InputDept As String
Dim InputStoreNumber As String
Dim InputYear As String
Dim SheetNamePattern As String
Dim wks As Worksheet
Dim HowManyMadeVisible As Long
Set MainWks = ActiveSheet
'pick up those choices
With MainWks
InputDept = .Range("Input_Dept")
InputStoreNumber = .Range("Input_StoreNumber")
InputYear = .Range("Input_Year")
End With
If InputDept = "" _
And InputStoreNumber = "" _
And InputYear = "" Then
'nothing chosen
MsgBox "Please make some choices!"
Exit Sub
End If
'replace missing values with wildcards (*)
'to match anything
If InputDept = "" Then
InputDept = "*"
End If
If InputStoreNumber = "" Then
InputStoreNumber = "*"
End If
If InputYear = "" Then
InputYear = "*"
End If
SheetNamePattern = InputStoreNumber & " " & InputDept & " " & InputYear
HowManyMadeVisible = 0
For Each wks In ThisWorkbook.Worksheets
Select Case LCase(wks.Name)
'add any sheets that shouldn't be touched to this
'list of sheetnames
Case Is = LCase(MainWks.Name), "sheetwithlistsonit"
'do nothing, keep it visible or hidden
Case Else
If LCase(wks.Name) Like LCase(SheetNamePattern) Then
HowManyMadeVisible = HowManyMadeVisible + 1
wks.Visible = xlSheetVisible
Else
'maybe??????
wks.Visible = xlSheetHidden
End If
End Select
Next wks
If HowManyMadeVisible = 0 Then
MsgBox "There were no worksheet names that matched your pattern"
Else
MsgBox HowManyMadeVisible & " worksheets made visible"
End If
End Sub
If you're new to macros:
Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html
David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm
(General, Regular and Standard modules all describe the same thing.)