justanotheruser
Board Regular
- Joined
- Aug 14, 2010
- Messages
- 96
Hi all,
This will be a simple fix for you clever VBA people out there. The highlighted code below basically means that if you select any option from a drop down list (E4 is a drop down list) other than Select Entity - the first option, then the Other and BL_PS worksheets will be opened.
Unfortunately, this doesn't work and it will not show either of the sheets on any of the selections including select entity - if I put an "Or" operator instead of "And" on that line, then it will work for just other - I'm going to have multiple about 20 sheets that need to be visible if anything other than select entity is chosen - so I would really appreciate a fix!
Thanks in advance for your help
This will be a simple fix for you clever VBA people out there. The highlighted code below basically means that if you select any option from a drop down list (E4 is a drop down list) other than Select Entity - the first option, then the Other and BL_PS worksheets will be opened.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long, i As Long
ActiveWorkbook.Unprotect
If Target.Address(False, False) = "E4" Then
If Target.Value = "Select Entity" Then
For i = 1 To Worksheets.Count
If Sheets(i).Name <> "Title" Then Sheets(i).Visible = False
Next i
Exit Sub
Sheets("Other").Visible = False
End If
Application.ScreenUpdating = False
For i = 1 To Worksheets.Count
If Sheets(i).Name <> "Title" Then Sheets(i).Visible = False
Next i
With Sheets("Mapping")
LR = .Range("C" & Rows.Count).End(xlUp).Row
For i = 3 To LR
If Target.Value = .Range("C" & i).Value And .Range("D" & i).Value <> "" Then Sheets(.Range("D" & i).Value).Visible = True
Next i
End With
[COLOR="Red"] If Target.Value <> "Select Entity" Then Sheets("Other").Visible = True And Sheets("BL_PS").Visible = True[/COLOR]
Application.ScreenUpdating = True
End If
ActiveWorkbook.Protect Structure:=True, Windows:=False
End Sub
Unfortunately, this doesn't work and it will not show either of the sheets on any of the selections including select entity - if I put an "Or" operator instead of "And" on that line, then it will work for just other - I'm going to have multiple about 20 sheets that need to be visible if anything other than select entity is chosen - so I would really appreciate a fix!
Thanks in advance for your help