cmefly
Well-known Member
- Joined
- May 13, 2003
- Messages
- 683
any idea why this won't work...
i've got a drop-down menu (A1) and in B1 i have a vlookup formula that can equal one of three result (x, y, or z).
i'm trying to hide and unhide rows based on the value in b1.
any ideas?
Private Sub worksheet_change()
Dim therange As Range
Dim i As Integer
therange = Range("w22:ab104")
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "x" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("37:123").Select
Selection.EntireRow.Hidden = True
End If
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "y" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("22:37").Select
Selection.EntireRow.Hidden = True
Rows("97:123").Select
Selection.EntireRow.Hidden = True
End If
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "z" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("22:96").Select
Selection.EntireRow.Hidden = True
End If
End Sub
i've got a drop-down menu (A1) and in B1 i have a vlookup formula that can equal one of three result (x, y, or z).
i'm trying to hide and unhide rows based on the value in b1.
any ideas?
Private Sub worksheet_change()
Dim therange As Range
Dim i As Integer
therange = Range("w22:ab104")
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "x" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("37:123").Select
Selection.EntireRow.Hidden = True
End If
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "y" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("22:37").Select
Selection.EntireRow.Hidden = True
Rows("97:123").Select
Selection.EntireRow.Hidden = True
End If
If Application.VLookup(Range("b20").Value, therange, 4, 0) = "z" Then
Rows("22:123").Select
Selection.EntireRow.Hidden = False
Rows("22:96").Select
Selection.EntireRow.Hidden = True
End If
End Sub