I have two codes in one worksheet.
Both works. Not sure how to combine these two into one. Wonder if anyone could help?
Private Sub Worksheet_Change(ByVal Target As Range)
Rows("54:103").EntireRow.Hidden = False
x = Range("A29").Value
Select Case x
Case "": Rows("54:103").EntireRow.Hidden = True
Case 1: Rows("55:103").EntireRow.Hidden = True
Case 2: Rows("56:103").EntireRow.Hidden = True
Case 3: Rows("57:103").EntireRow.Hidden = True
Case 4: Rows("58:103").EntireRow.Hidden = True
Case 5: Rows("59:103").EntireRow.Hidden = True
Case 6: Rows("60:103").EntireRow.Hidden = True
Case 7: Rows("61:103").EntireRow.Hidden = True
Case 8: Rows("62:103").EntireRow.Hidden = True
Case 9: Rows("63:103").EntireRow.Hidden = True
Case 10: Rows("64:103").EntireRow.Hidden = True
Case 11: Rows("65:103").EntireRow.Hidden = True
Case 12: Rows("66:103").EntireRow.Hidden = True
Case 13: Rows("67:103").EntireRow.Hidden = True
Case 14: Rows("68:103").EntireRow.Hidden = True
Case 15: Rows("69:103").EntireRow.Hidden = True
Case 16: Rows("70:103").EntireRow.Hidden = True
Case 17: Rows("71:103").EntireRow.Hidden = True
Case 18: Rows("72:103").EntireRow.Hidden = True
Case 19: Rows("73:103").EntireRow.Hidden = True
Case 20: Rows("74:103").EntireRow.Hidden = True
Case 21: Rows("75:103").EntireRow.Hidden = True
Case 22: Rows("76:103").EntireRow.Hidden = True
Case 23: Rows("77:103").EntireRow.Hidden = True
Case 24: Rows("78:103").EntireRow.Hidden = True
Case 25: Rows("79:103").EntireRow.Hidden = True
Case 26: Rows("80:103").EntireRow.Hidden = True
Case 27: Rows("81:103").EntireRow.Hidden = True
Case 28: Rows("82:103").EntireRow.Hidden = True
Case 29: Rows("83:103").EntireRow.Hidden = True
Case 30: Rows("84:103").EntireRow.Hidden = True
Case 31: Rows("85:103").EntireRow.Hidden = True
Case 32: Rows("86:103").EntireRow.Hidden = True
Case 33: Rows("87:103").EntireRow.Hidden = True
Case 34: Rows("88:103").EntireRow.Hidden = True
Case 35: Rows("89:103").EntireRow.Hidden = True
Case 36: Rows("90:103").EntireRow.Hidden = True
Case 37: Rows("91:103").EntireRow.Hidden = True
Case 38: Rows("92:103").EntireRow.Hidden = True
Case 39: Rows("93:103").EntireRow.Hidden = True
Case 40: Rows("94:103").EntireRow.Hidden = True
Case 41: Rows("95:103").EntireRow.Hidden = True
Case 42: Rows("96:103").EntireRow.Hidden = True
Case 43: Rows("97:103").EntireRow.Hidden = True
Case 44: Rows("98:103").EntireRow.Hidden = True
Case 45: Rows("99:103").EntireRow.Hidden = True
Case 46: Rows("100:103").EntireRow.Hidden = True
Case 47: Rows("101:103").EntireRow.Hidden = True
Case 48: Rows("102:103").EntireRow.Hidden = True
Case 49: Rows("103:103").EntireRow.Hidden = True
Case 50: Rows("103:104").EntireRow.Hidden = False
End Select
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Address = "$C$2" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
Both works. Not sure how to combine these two into one. Wonder if anyone could help?
Private Sub Worksheet_Change(ByVal Target As Range)
Rows("54:103").EntireRow.Hidden = False
x = Range("A29").Value
Select Case x
Case "": Rows("54:103").EntireRow.Hidden = True
Case 1: Rows("55:103").EntireRow.Hidden = True
Case 2: Rows("56:103").EntireRow.Hidden = True
Case 3: Rows("57:103").EntireRow.Hidden = True
Case 4: Rows("58:103").EntireRow.Hidden = True
Case 5: Rows("59:103").EntireRow.Hidden = True
Case 6: Rows("60:103").EntireRow.Hidden = True
Case 7: Rows("61:103").EntireRow.Hidden = True
Case 8: Rows("62:103").EntireRow.Hidden = True
Case 9: Rows("63:103").EntireRow.Hidden = True
Case 10: Rows("64:103").EntireRow.Hidden = True
Case 11: Rows("65:103").EntireRow.Hidden = True
Case 12: Rows("66:103").EntireRow.Hidden = True
Case 13: Rows("67:103").EntireRow.Hidden = True
Case 14: Rows("68:103").EntireRow.Hidden = True
Case 15: Rows("69:103").EntireRow.Hidden = True
Case 16: Rows("70:103").EntireRow.Hidden = True
Case 17: Rows("71:103").EntireRow.Hidden = True
Case 18: Rows("72:103").EntireRow.Hidden = True
Case 19: Rows("73:103").EntireRow.Hidden = True
Case 20: Rows("74:103").EntireRow.Hidden = True
Case 21: Rows("75:103").EntireRow.Hidden = True
Case 22: Rows("76:103").EntireRow.Hidden = True
Case 23: Rows("77:103").EntireRow.Hidden = True
Case 24: Rows("78:103").EntireRow.Hidden = True
Case 25: Rows("79:103").EntireRow.Hidden = True
Case 26: Rows("80:103").EntireRow.Hidden = True
Case 27: Rows("81:103").EntireRow.Hidden = True
Case 28: Rows("82:103").EntireRow.Hidden = True
Case 29: Rows("83:103").EntireRow.Hidden = True
Case 30: Rows("84:103").EntireRow.Hidden = True
Case 31: Rows("85:103").EntireRow.Hidden = True
Case 32: Rows("86:103").EntireRow.Hidden = True
Case 33: Rows("87:103").EntireRow.Hidden = True
Case 34: Rows("88:103").EntireRow.Hidden = True
Case 35: Rows("89:103").EntireRow.Hidden = True
Case 36: Rows("90:103").EntireRow.Hidden = True
Case 37: Rows("91:103").EntireRow.Hidden = True
Case 38: Rows("92:103").EntireRow.Hidden = True
Case 39: Rows("93:103").EntireRow.Hidden = True
Case 40: Rows("94:103").EntireRow.Hidden = True
Case 41: Rows("95:103").EntireRow.Hidden = True
Case 42: Rows("96:103").EntireRow.Hidden = True
Case 43: Rows("97:103").EntireRow.Hidden = True
Case 44: Rows("98:103").EntireRow.Hidden = True
Case 45: Rows("99:103").EntireRow.Hidden = True
Case 46: Rows("100:103").EntireRow.Hidden = True
Case 47: Rows("101:103").EntireRow.Hidden = True
Case 48: Rows("102:103").EntireRow.Hidden = True
Case 49: Rows("103:103").EntireRow.Hidden = True
Case 50: Rows("103:104").EntireRow.Hidden = False
End Select
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Address = "$C$2" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub