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
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