I've got some code that was developed in a tool I'm working on that performs some basic calculations for adding dates, etc. based on the change of another cell. It works fine in the sheet it was created for, however, when I copy it into another sheet module for a similar task (two extra columns added) it doesn't appear to be working. I've changed the references to account for the two extra columns, and I don't receive any error messages, it just doesn't do the calculations it's supposed to. I am a VBA novice and just can't seem to figure it out. Thanks in advance for the help!
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo SelectError:
Oval = Target.Value
SelectError:
End Sub
Private Sub Worksheet_Change2(ByVal Target As Range)
If Not Intersect(Target, Range("G11:G202")) Is Nothing Then
On Error GoTo Eerror:
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Password"
'Dim TarAddress As String
Range(Target.Address).Select ''''DO NOT DELETE, PREVENTS LOOP
If Range(Target.Address).Value <> 0 Then
Range(Target.Address).Offset(0, 1).Value = Date
'Update Budget
If Range(Target.Address).Offset(0, 5).Value = 0 Then
Range(Target.Address).Offset(0, 5).Value = Range(Target.Address).Value
End If
If Range(Target.Address).Value <> 0 Then
Range(Target.Address).Offset(0, 6).Value = Range(Target.Address).Value
End If
'Set Task Status to Not Started in Cancelled
If Range(Target.Address).Offset(0, 2).Value = "Cancelled" Then
Range(Target.Address).Offset(0, 2).Value = "Not Started"
End If
End If
Eerror:
ActiveWorkbook.Protect Password:="Password"
End If
If Not Intersect(Target, Range("I11:I202")) Is Nothing Then
On Error GoTo GError:
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Password"
'Dim TarAddress As String
Range(Target.Address).Select ''''DO NOT DELETE, PREVENTS LOOP
'Mark Complete Date
If Range(Target.Address).Value = "Complete" Or Range(Target.Address).Value = "Complete w/ Issues" Then
Range(Target.Address).Offset(0, 2).Value = Date
Range(Target.Address).Offset(0, -2).Value = 0
End If
'Mark Start Date w/ Complete Date if Blank
If (Range(Target.Address).Value = "Complete" Or Range(Target.Address).Value = "Complete w/ Issues") And Range(Target.Address).Offset(0, 1).Value = "" Then
Range(Target.Address).Offset(0, 1).Value = Date
End If
'Mark Start Date
If Range(Target.Address).Value = "In Progress" And Range(Target.Address).Offset(0, 1).Value = "" Then
Range(Target.Address).Offset(0, 1).Value = Date
End If
'Mark Cancel Date
If Range(Target.Address).Value = "Cancelled" And Range(Target.Address).Offset(0, 8).Value = 1 Then
Range(Target.Address).Offset(0, 13).Value = Date
End If
GError:
ActiveWorkbook.Protect Password:="Password"
End If
End Sub
ETA: I don't know if it's because it's in a sheet vs a module, but it won't let me step through the code to try to track it. An example of what I'm expecting, is that if I put in a value greater than 0 in a cell in column G, it will update the next cell over with today's date, copy and paste that value into cells 5 and 6 columns over, and a few other things. It doesn't make any changes like this when I do put in a value, nor does it give an error message. The sheet just remains unchanged.