How do I automatically hid rows on a cell selection?

garygrung

New Member
Joined
Dec 22, 2008
Messages
3
Hi

In one cell I have a Data Validation list so the users can choose a question. (Source: Choose, Automation?, No Automation?)

If they choose "Choose" I would like to hide rows 59 to 79.
If they choose "Automation?" I would like to hide rows 59 to 63.
And if they choose "No automation?" I would like to hide rows 64 to 79.


I have tried:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Integer
Application.ScreenUpdating = False
If Range("C56:C56") = "Automation?" Then
        For i = 59 To 63
            Rows(i).RowHeight = 0
        Next i
      Else
        For i = 59 To 63
            Rows(i).RowHeight = 18.75
        Next i
    End If
End Sub
Great if I want to use one selection but not multiple.

Can you please help?

Thanks
Gary :mad:
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

MrKowz

Well-known Member
Joined
Jun 30, 2008
Messages
6,653
Office Version
365, 2016
Platform
Windows
Welcome to the boards!

Try the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Rows(59 & ":" & 79).Hidden = False
Select Case Range("C56").value
    Case "Choose"
        Rows(59 & ":" & 79).Hidden = True
    Case "Automation?"
        Rows(59 & ":" & 63).Hidden = True
    Case "No automation?"
        Rows(64 & ":" & 79).Hidden = True
End Select
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,095,361
Messages
5,444,020
Members
405,260
Latest member
Khauff

This Week's Hot Topics

Top