New to VBA - Using multiple dropdown lists to hide/unhide rows.

PeeGeeBee

New Member
Joined
Feb 14, 2018
Messages
1
Hi,

I am very new to VBA and have spent hours searching for the answer to something I'm sure you will all easily be able to help me solve.

I am creating an Excel form which expands (unhiding rows) as the user selects drop down options.

The first half of the code below works perfectly. When an "employee type" is chosen it will unhide the relevant rows which contain further drop downs.

Unfortunately, The second half of the code, which I intend to hide/unhide further rows depending on drop down selection chosen is doing nothing.

How do I create a code where I can add further drop down lists which can have rows hide/unhide based on the list selection?

Thank you for any help.

Paul

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$13" Then 'Check if the changed value is indeed in E13
    If Target.Value = "Choose an Employee Type" Then
        ActiveSheet.Rows("15:18").EntireRow.Hidden = True 'Hide Teaching Staff and Support staff if the value is Choose an Employee Type
    ElseIf Target.Value = "Teaching Staff" Then
        ActiveSheet.Rows("15:18").EntireRow.Hidden = False 'Show Teaching Staff
        ActiveSheet.Rows("19:22").EntireRow.Hidden = True 'Hide Support Staff
    ElseIf Target.Value = "Support Staff" Then
        ActiveSheet.Rows("19:22").EntireRow.Hidden = False 'Show Support Staff
        ActiveSheet.Rows("15:18").EntireRow.Hidden = True 'Hide Teaching Staff
    ElseIf Target.Value = " " Then
    End If
End If
End Sub
Sub NewStarter()
If Target.Address = "$E$16" Then 'Check if the changed value is indeed in E16
    If Target.Value = "Select Document Type" Then
        ActiveSheet.Rows("32:53").EntireRow.Hidden = True 'Hide personal details for New Starter
    ElseIf Target.Value = "New Starter" Then
        ActiveSheet.Rows("32:53").EntireRow.Hidden = False 'Show personal details for new stater section
    ElseIf Target.Value = " " Then
    End If
End If
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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