Ammend macro to keep an additional sheet unhidden

DLJ98

New Member
Joined
Jan 18, 2018
Messages
1
I have a spreadsheet that hides other sheets depending on the value of one of my data validations, however I can't work out how to adjust my code currently written to keep the costing sheet from hiding every time I adjust the data validation (other than naming it with all the possible outcomes of my data validation). The code is below:

On the Worksheet it is:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = Range("SelectType").Address Then
    Select Case Target.Value
      Case "Admin Lists"
        ShowAllSheets
      Case ""
        'do nothing
      Case Else
        ShowSelSheets
    End Select
  End If
End Sub

And then the general declarations are:

Code:
Option Explicit
Sub ShowAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
  ws.Visible = xlSheetVisible
Next ws
End Sub

Sub ShowSelSheets()
Dim ws As Worksheet
Dim strType As String
strType = Worksheets("Chiller Selection").Range("SelectType").Value
For Each ws In ActiveWorkbook.Sheets
  If InStr(1, ws.Name, strType) > 0 Then
    ws.Visible = xlSheetVisible
  Else
    If ws.Name <> "Chiller Selection" Then
      ws.Visible = xlSheetHidden
    End If
  End If
Next ws
End Sub
 
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top