Multiple options in VBA Drop down option

I heart Excel

Board Regular
Joined
Feb 28, 2011
Messages
66
Hello,

Sorry to ask again, I really do appreciate your help.

I have a drop down list of names, and want a certain name to bring up a particular hidden field. I currently have the following which keeps erroring. Any ideas?

Private Sub Worksheet_Change(ByVal Target As Range)

Select Case Target.Address
Case "$B$9"
If UCase(Target.Value) = "BOBBY BROWN" And "JOHN LENNON" Then
Rows("16:17").EntireRow.Hidden = True
ElseIf UCase(Target.Value) = "ROGER REDHAT" And "JENNIFER YELLOW" Then
Rows("16:17").EntireRow.Hidden = False
End If

Case "$D$19"
If UCase(Target.Value) = "NO" Then
Rows("20:24").EntireRow.Hidden = True
ElseIf UCase(Target.Value) = "YES" Then
Rows("20:24").EntireRow.Hidden = False
End If

Case Else
Exit Sub
End Select
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
this syntax is invalid

Code:
If UCase(Target.Value) = "BOBBY BROWN" And "JOHN LENNON" Then

maybe you mean

Code:
If UCase(Target.Value) = "BOBBY BROWN" or UCase(Target.Value) = "JOHN LENNON" Then
 
Upvote 0
Thanks that worked.

I also need something for -

Case "$D$19"
If UCase(Target.Value) = "NO" Then
Rows("20:24").EntireRow.Hidden = True
ElseIf UCase(Target.Value) = "YES" Then
Rows("20:24").EntireRow.Hidden = False

End If


I want Row 15 to also be hidden if the target value is "YES" tried putting in all sorts, but still keep getting errors!
 
Upvote 0
Code:
Case "$D$19"
If UCase(Target.Value) = "NO" Then
Rows("20:24").EntireRow.Hidden = True
ElseIf UCase(Target.Value) = "YES" Then
Rows("20:24").EntireRow.Hidden = False
Rows("15:15").EntireRow.Hidden = True
End If
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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