View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Bernard Liengme[_3_] Bernard Liengme[_3_] is offline
external usenet poster
 
Posts: 1,104
Default conditionally hiding rows

Great feedback! I'm off to buy a large-sized hat
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Derrick" wrote in message
...
Right now, you surpass Batman on my list of awesome superheros.

Thank you!

"Bernard Liengme" wrote:

I will assume the dropdown box relates to cell A1 on Sheet1
Right click the Sheet1 tab; use View code and paste this subroutine

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub

Rows("22:29").EntireRow.Hidden = False
If Range("A1") = "A" Then
Rows("23:24").EntireRow.Hidden = True
Rows("26:26").EntireRow.Hidden = True
ElseIf Range("A1") = "B" Then
Rows("25:25").EntireRow.Hidden = True
Rows("27:28").EntireRow.Hidden = True
ElseIf Range("A1") = "C" Then
Rows("21:22").EntireRow.Hidden = True
Rows("29:29").EntireRow.Hidden = True
End If
End Sub

Whenever the value inA1 changes, the subroutine will run
Just alter "A1" to suit your needs
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Derrick" wrote in message
...
can anyone help me figure out this problem?
I have an drop down option list, and i would like to create an if
statement
that will hide select rows depending on which option is selected:
ie if option A is checked,
then rows 23,24, 26 are hidden.
if option b is checked,
rows 25, 27,28 are hidden
and if option c is checked
rows 21 22 29 are hidden.
simple enough i hope?

thanks!