View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TonyM TonyM is offline
external usenet poster
 
Posts: 10
Default Code to hide rows based on cell contents

Hi Tim

Trye this:-

Private Sub Worksheet_Change(ByVal Target As Range)

Rows("6:18").EntireRow.Hidden = False

If Range("a1") = "a" Then
Rows("6:9").EntireRow.Hidden = True
ElseIf Range("a1") = "b" Then
Rows("10:18").EntireRow.Hidden = True
End If

End Sub

-----Original Message-----
Hi

I have a cost model, you have to answer a set of
questions. The set of questions depends on which of 3
options is selected in a cell (i've used a data
validation list).
I'm new to VB in Excel and I need something like this:

If Selection Cell = option A
Hide Rows 6-9
If Selection Cell = option B
Hide Rows 10-18
Else
Show all of them

Any suggestions?
TIA
tim
.