brijeshkeni
New Member
Dear All,
I was trying to use two worksheet_change macros in one sheet further to which i was getting error. Can you please advise what could be wrong? the macros are defined below.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Target.Parent.Range("E48")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
Select Case Target
Case ""
Rows("49:54").Hidden = True
Case "1"
Rows("50:50").Hidden = False
Rows("51:54").Hidden = True
Rows("55:55").Hidden = False
Case "2"
Rows("50:51").Rows.Hidden = False
Rows("52:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "3"
Rows("50:52").Rows.Hidden = False
Rows("53:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "4"
Rows("50:53").Rows.Hidden = False
Rows("54:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "5"
Rows("50:54").Rows.Hidden = False
Rows("55:55").Hidden = False
End Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Target.Parent.Range("D27")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
Select Case Target
Case ""
Rows("28:33").Hidden = True
Case "1"
Rows("28:29").Hidden = False
Rows("30:33").Hidden = True
Case "2"
Rows("28:30").Rows.Hidden = False
Rows("31:33").Rows.Hidden = True
Case "3"
Rows("28:31").Rows.Hidden = False
Rows("32:33").Rows.Hidden = True
Case "4"
Rows("28:32").Rows.Hidden = False
Rows("33:33").Rows.Hidden = True
Case "5"
Rows("28:33").Rows.Hidden = False
End Select
End Sub
I was trying to use two worksheet_change macros in one sheet further to which i was getting error. Can you please advise what could be wrong? the macros are defined below.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Target.Parent.Range("E48")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
Select Case Target
Case ""
Rows("49:54").Hidden = True
Case "1"
Rows("50:50").Hidden = False
Rows("51:54").Hidden = True
Rows("55:55").Hidden = False
Case "2"
Rows("50:51").Rows.Hidden = False
Rows("52:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "3"
Rows("50:52").Rows.Hidden = False
Rows("53:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "4"
Rows("50:53").Rows.Hidden = False
Rows("54:54").Rows.Hidden = True
Rows("55:55").Hidden = False
Case "5"
Rows("50:54").Rows.Hidden = False
Rows("55:55").Hidden = False
End Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Target.Parent.Range("D27")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
Select Case Target
Case ""
Rows("28:33").Hidden = True
Case "1"
Rows("28:29").Hidden = False
Rows("30:33").Hidden = True
Case "2"
Rows("28:30").Rows.Hidden = False
Rows("31:33").Rows.Hidden = True
Case "3"
Rows("28:31").Rows.Hidden = False
Rows("32:33").Rows.Hidden = True
Case "4"
Rows("28:32").Rows.Hidden = False
Rows("33:33").Rows.Hidden = True
Case "5"
Rows("28:33").Rows.Hidden = False
End Select
End Sub