Hi
I’m trying to produce a spreadsheet to hide a number of different rows depending upon the value of a particular cell.
I’ve tried to use worksheet related events but I just can’t get it to work.
Here is the code
**************************************************
Private Sub worksheet_change(ByVal Target As Range)
Dim myrange As Range
Set myrange = ActiveCell
Application.ScreenUpdating = False
If Target.Address = Range("Type_Select") Then
Select Case Range("Type_Select").Value
Case ""
Case "Type 1"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("26:52").Select
Selection.EntireRow.Hidden = True
Case "Type 2"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("53:70").Select
Selection.EntireRow.Hidden = True
Case "Type 3"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("71:98").Select
Selection.EntireRow.Hidden = True
Case "Type 4"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("99:128").Select
Selection.EntireRow.Hidden = True
End Select
Else
End If
myrange.Select
Application.ScreenUpdating = True
End Sub
I’m trying to produce a spreadsheet to hide a number of different rows depending upon the value of a particular cell.
I’ve tried to use worksheet related events but I just can’t get it to work.
Here is the code
**************************************************
Private Sub worksheet_change(ByVal Target As Range)
Dim myrange As Range
Set myrange = ActiveCell
Application.ScreenUpdating = False
If Target.Address = Range("Type_Select") Then
Select Case Range("Type_Select").Value
Case ""
Case "Type 1"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("26:52").Select
Selection.EntireRow.Hidden = True
Case "Type 2"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("53:70").Select
Selection.EntireRow.Hidden = True
Case "Type 3"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("71:98").Select
Selection.EntireRow.Hidden = True
Case "Type 4"
Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("99:128").Select
Selection.EntireRow.Hidden = True
End Select
Else
End If
myrange.Select
Application.ScreenUpdating = True
End Sub