I have three codes, which works independently. but when i put them together only one of the codes work. I have limited knowledge in these. Mostly, I just google and try to edit from others code to fit my purpose. I was wondering if anyone can help for my case. Your help is very much appreciated. thank you.
Private Sub Worksheet_Change(ByVal Target As Range)
AddDate Target
Addc Target
Dropdown Target
End Sub
Sub AddDate(Target As Range)
Application.EnableEvents = False
If Target.Column = 2 Then
Select Case UCase(Target.Value)
Case "2"
Target.Value = "2PN"
Case "1"
Target.Value = "1PN"
Case "0"
Target.Value = "0PN"
Case "3"
Target.Value = "3PN"
Case "M"
Target.Value = "MI"
Case "G"
Target.Value = "GV"
End Select
End If
Application.EnableEvents = True
End Sub
Sub Addc(Target As Range)
Application.EnableEvents = False
If Target.Column = 3 Then
Select Case UCase(Target.Value)
Case "1"
Target.Value = "1C"
Case "2"
Target.Value = "2C"
End Select
End If
Application.EnableEvents = True
End Sub
Sub Dropdown(Target As Range)
Dim Oldvalue As String, Newvalue As String
'On Error GoTo Exitsub
Application.ScreenUpdating = False
If Target.Address = "$B$9" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Or Target.Value = "" Then
Application.EnableEvents = True
Exit Sub
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
Application.EnableEvents = True
Else
Rows("24:73").EntireRow.Hidden = False
x = Range("B14").Value
Select Case x
Case ""
Rows("24:73").EntireRow.Hidden = True
Case 1 To 49
Rows(24 + x & ":73").EntireRow.Hidden = True
Case 50
End Select
End If
Application.ScreenUpdating = True
End Sub
` Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String, Newvalue As String
'On Error GoTo Exitsub
Application.ScreenUpdating = False
If Target.Address = "$B$9" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Or Target.Value = "" Then
Application.EnableEvents = True
Exit Sub
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
Application.EnableEvents = True
Else
Rows("24:73").EntireRow.Hidden = False
x = Range("B14").Value
Select Case x
Case ""
Rows("24:73").EntireRow.Hidden = True
Case 1 To 49
Rows(24 + x & ":73").EntireRow.Hidden = True
Case 50
End Select
End If
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
AddDate Target
Addc Target
Dropdown Target
End Sub
Sub AddDate(Target As Range)
Application.EnableEvents = False
If Target.Column = 2 Then
Select Case UCase(Target.Value)
Case "2"
Target.Value = "2PN"
Case "1"
Target.Value = "1PN"
Case "0"
Target.Value = "0PN"
Case "3"
Target.Value = "3PN"
Case "M"
Target.Value = "MI"
Case "G"
Target.Value = "GV"
End Select
End If
Application.EnableEvents = True
End Sub
Sub Addc(Target As Range)
Application.EnableEvents = False
If Target.Column = 3 Then
Select Case UCase(Target.Value)
Case "1"
Target.Value = "1C"
Case "2"
Target.Value = "2C"
End Select
End If
Application.EnableEvents = True
End Sub
Sub Dropdown(Target As Range)
Dim Oldvalue As String, Newvalue As String
'On Error GoTo Exitsub
Application.ScreenUpdating = False
If Target.Address = "$B$9" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Or Target.Value = "" Then
Application.EnableEvents = True
Exit Sub
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
Application.EnableEvents = True
Else
Rows("24:73").EntireRow.Hidden = False
x = Range("B14").Value
Select Case x
Case ""
Rows("24:73").EntireRow.Hidden = True
Case 1 To 49
Rows(24 + x & ":73").EntireRow.Hidden = True
Case 50
End Select
End If
Application.ScreenUpdating = True
End Sub
` Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String, Newvalue As String
'On Error GoTo Exitsub
Application.ScreenUpdating = False
If Target.Address = "$B$9" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Or Target.Value = "" Then
Application.EnableEvents = True
Exit Sub
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
Application.EnableEvents = True
Else
Rows("24:73").EntireRow.Hidden = False
x = Range("B14").Value
Select Case x
Case ""
Rows("24:73").EntireRow.Hidden = True
Case 1 To 49
Rows(24 + x & ":73").EntireRow.Hidden = True
Case 50
End Select
End If
Application.ScreenUpdating = True
End Sub