Hi -
I am trying to show / hide worksheets that start with a specific character based on a List selection. The following code will show or hide the worksheets however I can't figure out how to run the code based on a cell value.
For example, if B15 says "Show Detail" then show worksheets starting with "P". Consequently, if B15 says "Hide Detail, then hide worksheets starting with "P"
Sub ShowHideProject()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "P*" And ws.Visible = False Then
ws.Visible = xlSheetVisible
Else
If ws.Name Like "P*" And ws.Visible = True Then
ws.Visible = xlSheetHidden
End If
End If
Next ws
End Sub
I am trying to show / hide worksheets that start with a specific character based on a List selection. The following code will show or hide the worksheets however I can't figure out how to run the code based on a cell value.
For example, if B15 says "Show Detail" then show worksheets starting with "P". Consequently, if B15 says "Hide Detail, then hide worksheets starting with "P"
Sub ShowHideProject()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "P*" And ws.Visible = False Then
ws.Visible = xlSheetVisible
Else
If ws.Name Like "P*" And ws.Visible = True Then
ws.Visible = xlSheetHidden
End If
End If
Next ws
End Sub