Hey all,
I have some code on a few of my worksheets which makes some changes to others sheets when the cell values are changed. However, there is an issue. When I change the worksheet, the macro runs, but when I change it again, nothing happens.
Here is a sample of my code:
Also, if anyone could shorten the code for me please, I will be very greatful.
Thanks,
LSM1604
I have some code on a few of my worksheets which makes some changes to others sheets when the cell values are changed. However, there is an issue. When I change the worksheet, the macro runs, but when I change it again, nothing happens.
Here is a sample of my code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Call Module1.MonthSheetChange
If Target.Column = 5 Then
If Target.Row = 3 Or Target.Row = 4 Or Target.Row = 5 Or Target.Row = 6 Then
Application.EnableEvents = False
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N3").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N78").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N153").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N228").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N303").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N378").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N453").Value = Range("E3").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N4").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N79").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N154").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N229").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N304").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N379").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("N454").Value = Range("E4").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U3").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U78").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U153").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U228").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U303").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U378").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U453").Value = Range("E5").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U4").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U79").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U154").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U229").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U304").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U379").Value = Range("E6").Value
Sheet11.Unprotect Password:="BBEAK11"
Sheet11.Range("U454").Value = Range("E6").Value
Sheet11.Protect Password:="BBEAK11", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
ElseIf Target.Column = 12 Then
If Target.Row = 3 Or Target.Row = 4 Or Target.Row = 5 Or Target.Row = 6 Then
Application.EnableEvents = False
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N3").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N78").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N153").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N228").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N303").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N378").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N453").Value = Range("E3").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N4").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N79").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N154").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N229").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N304").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N379").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("N454").Value = Range("E4").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U3").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U78").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U153").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U228").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U303").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U378").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U453").Value = Range("E5").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U4").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U79").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U154").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U229").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U304").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U379").Value = Range("E6").Value
Sheet12.Unprotect Password:="BBEAK11"
Sheet12.Range("U454").Value = Range("E6").Value
Sheet12.Protect Password:="BBEAK11", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
End Sub
Also, if anyone could shorten the code for me please, I will be very greatful.
Thanks,
LSM1604