Multi down down options causes tabs to hide in VBA

LindseyAlden

New Member
Joined
May 29, 2019
Messages
1
Hi - I am working on a VBA to hide and unhide tabs in a single work book. I have a drop that consists of "Low", "Medium", "High", "Major".

With the "Low" choice, I want to hide tabs "Key", "Stakeholder Interest Influence", "Stakeholder Mgmt Plan", "Risk Mgmt Plan", and "Quality Mgmt Plan".
With "Medium" choice, I want to hide tabs "Key", "Stakeholder Interest Influence", "Risk Mgmt Plan", and "Quality Mgmt Plan".
With "High" choice, I want to hide tabs "Key" and "Stakeholder Interest Influence"
With "Major" choice, I want to hide tabs "Key"
With no choice, I just want tabs "Key" hidden

Currently, I have the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If [Level_of_effort] = "Low" Then
Sheets("Key").Visible = False
Sheets("Stakeholder Interest Influence").Visible = False
Sheets("Stakeholder Mgmt Plan").Visible = False
Sheets("Risk Mgmt Plan").Visible = False
Sheets("Quality Mgmt Plan").Visible = False
Else
Sheets("Key").Visible = False
Sheets("Stakeholder Interest Influence").Visible = True
Sheets("Stakeholder Mgmt Plan").Visible = True
Sheets("Risk Mgmt Plan").Visible = True
Sheets("Quality Mgmt Plan").Visible = True
End If

This works for the Low option, but I can't seem to string the Medium, High, and Major in there. Any help is Super appreciated!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Perhaps something like this.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim arrHideSheets As Variant

    Select Case [Level_Of_Effort]
        Case "Low"
            arrHideSheets = Array("Key", "Stakeholder Interest Influence", _
                                  "Stakeholder Mgmt Plan", "Risk Mgmt Plan", _
                                  "Quality Mgmt Plan")
        Case "Medium"
            arrHideSheets = Array("Key", "Stakeholder Interest Influence", _
                                  "Risk Mgmt Plan", "Quality Mgmt Plan")
        
        Case "High"
            arrHideSheets = Array("Key", "Stakeholder Interest Influence")
        
        Case Else
            arrHideSheets = Array("Key")
    End Select
    
    For Each ws In ThisWorkbook.Sheets
        ws.Visible = True
    Next ws

    Sheets(arrHideSheets).Visible = False
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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