Hi,
try this:
Option Explicit
Sub GetSheets()
On Error Resume Next
Dim i As Long, j As Long, lngRow As Long
Dim strSelectedModel As String
Dim blnWsVisible As Boolean
With ActiveWorkbook
'get model
strSelectedModel = .Worksheets("MODEL SELECTION SHEET").Range("P1").Value
'find appropriate row in 'index' sheet
For i = 1 To 24
If strSelectedModel = .Worksheets("index").Range("A" & i).Value Then lngRow = i
Next i
'hide/unhide accordingly
For i = 1 To .Worksheets.Count
blnWsVisible = False
For j = 2 To 9
If .Worksheets(i).Name <> "MODEL SELECTION SHEET" Then
If .Worksheets(i).Name = .Worksheets("index").Cells(lngRow, j).Value Then
blnWsVisible = True
GoTo SetVisibility
End If
Else
GoTo SkipWs
End If
Next j
SetVisibility:
If .Worksheets(i).Visible <> blnWsVisible Then .Worksheets(i).Visible = blnWsVisible
SkipWs:
Next i
End With
End Sub
like used in this example: Hide sheets in a Bill of Material.xlsm
Mark this thread SOLVED if this answer solved this problem.
Regards
Bookmarks