View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
guz guz is offline
external usenet poster
 
Posts: 10
Default Unhiding rows as a result of selection in dropdown list

I've tried the solution given and it works when I manually input the values.
However a) I want the macro to work from the value selected in the dropdown
list
b) To further complicate matters I would want something similar with a
second dropdown!
alan g

"Dave Peterson" wrote:

If you're using data|validation, you can use a macro:

If you want to try...

Rightclick on the worksheet tab that should have this behavior. Select View
code and paste this into the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then
Exit Sub 'single cell at a time
End If

If Intersect(Target, Me.Range("a1")) Is Nothing Then
Exit Sub
End If

Me.Rows.Hidden = False
Select Case LCase(Target.Value)
Case Is = LCase("a")
Me.Range("a2").Resize(12).EntireRow.Hidden = True
Case Is = LCase("b")
Me.Range("a22").Resize(7).EntireRow.Hidden = True
End Select

End Sub

My test routine checks for a change in A1. If it sees "a", then it hides rows 2
to 13 (resizes to 12 rows). If it sees "b", it hides rows 22 to 28 (resizes to
7 rows).

It also unhides all the rows before it checks what changed.

guz wrote:

How can I set something up that when a value from a dropdown list is selected
then a range of rows are unhidden then when another value is selected a
different range is unhidden?


--

Dave Peterson