earldunning
Active Member
- Joined
- Nov 9, 2006
- Messages
- 263
Hello,
I have a worksheet that does some checking if certain cells are changed.
The worksheet is to gather information for software code to be implemented. One of the fields is "Release Number" which is the designated release they wish to implement the code.
If the date is too close to the actual implementation, the user can not move into or out of the release in the normal way. I have a "Lock down" date that I compare to today.
The code is perplexing me. I need to check that the release field (B15) is not being moved into a locked down release or out of. The "into" part is working fine and the "out of" is pretty similar code but puts it into an infinite loop.
The code in red is doing an infinite loop. The code in green is not. I have even tried replacing the NewLockDate in the good code withe CurrentLockDate but that throws it into a loop also.
Obviously it thinks it changing again and starts the code again. but why does it only loop for the first one and the others are fine? Any Ideas?
I have a worksheet that does some checking if certain cells are changed.
The worksheet is to gather information for software code to be implemented. One of the fields is "Release Number" which is the designated release they wish to implement the code.
If the date is too close to the actual implementation, the user can not move into or out of the release in the normal way. I have a "Lock down" date that I compare to today.
The code is perplexing me. I need to check that the release field (B15) is not being moved into a locked down release or out of. The "into" part is working fine and the "out of" is pretty similar code but puts it into an infinite loop.
The code in red is doing an infinite loop. The code in green is not. I have even tried replacing the NewLockDate in the good code withe CurrentLockDate but that throws it into a loop also.
Obviously it thinks it changing again and starts the code again. but why does it only loop for the first one and the others are fine? Any Ideas?
Code:
Dim NewLockDate As Date
Dim CurrentLockDate As Date
Dim DateToday As Date
Dim GoBack As Boolean
DateToday = Format(Now, "m/dd/yyyy")
If Target.Address(False, False) = "B15" And Range("B15").Value <> "" Then
Range("Q2").Select
Selection.Copy
Range("Q3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
CurrentLockDate = Range("Q3").Value
CurrentLockDate = Format(CurrentLockDate, "m/dd/yyyy")
If DateToday > CurrentLockDate Then
'MsgBox ("New Lock date is " & NewLockDate)
MsgBox ("Current Lock date is " & CurrentLockDate)
MsgBox ("It is aleady past the scope lock date for this release. You can not add/modify/remove deliverables in the normal fashion. You must use a change form. To move the data to the Change Form use the button to the right.")
[COLOR="Red"]Range("B15").Value = Range("Q1").Value[/COLOR]
GoTo 10
End If
Range("Q4").Value = "=VLOOKUP(ReleaseNumberValue,ReleaseDatesList,7,0)"
Range("Q4").Select
Selection.Copy
Range("Q4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
NewLockDate = Range("Q4").Value
NewLockDate = Format(NewLockDate, "m/dd/yyyy")
Range("Q4").Value = ""
MsgBox ("New Lock date is " & NewLockDate)
MsgBox ("Current Lock date is " & CurrentLockDate)
If DateToday > NewLockDate Then
MsgBox ("It is aleady past the scope lock date for the release. You can not add/modify/remove deliverables in the normal fashion. You must use a change form. To move the data to the Change Form use the button to the right.")
[COLOR="SeaGreen"] Range("B15").Value = Range("Q1").Value[/COLOR]
GoTo 10
Else
[COLOR="seagreen"]Range("Q1").Value = Range("B15").Value[/COLOR]
Range("B21").Value = "=VLOOKUP(ReleaseNumberValue,ReleaseDatesList,2,0)"
Range("B22").Value = "=VLOOKUP(ReleaseNumberValue,ReleaseDatesList,3,0)"
Range("B23").Value = "=VLOOKUP(ReleaseNumberValue,ReleaseDatesList,4,0)"
Range("B24").Value = "=VLOOKUP(ReleaseNumberValue,ReleaseDatesList,5,0)"
Range("B21:B24").Select
Selection.Copy
Range("B21").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B16").Select
Application.CutCopyMode = False
End If
'ActiveSheet.Unprotect Password:="security"
End If
10