Private Sub Worksheet_Change(ByVal Target As Range)
' If the target column is greater than J And J isn't blank And K is blank then...
If Target.Column > 9 And (Range("C" & Target.Row).Value = "CP" Or Range("C" & Target.Row).Value = "NCD") And (Range("I" & Target.Row).Value = "" Or Range("I" & Target.Row).Value <= "0") Then
' Display error message to this effect
MsgBox "Error! If Mode=CP/NCD Please Enter Coupon rates before moving on"
' Disable events to prevent infinite loop
Application.EnableEvents = False
' Clear the contents of the target cell
Target.ClearContents
' Re-enable events
Application.EnableEvents = True
' Select column K of the target row
Range("I" & Target.Row).Select
End If
Dim FG As Range, t As Range, v As Variant
Dim r As Long
Set t = Target
Set FG = Range("F:G")
If Intersect(t, FG) Is Nothing Then Exit Sub
Application.EnableEvents = False
r = t.Row
v = t.Value
If v = "" Then
Range("F" & r & ":G" & r).Value = ""
End If
If IsNumeric(v) Then
If Intersect(t, Range("G:G")) Is Nothing Then
t.Offset(0, 1).Value = v / 365 * 12
Else
t.Offset(0, -1).Value = v / 12 * 365
End If
End If
Application.EnableEvents = True
End Sub
' If the target column is greater than J And J isn't blank And K is blank then...
If Target.Column > 9 And (Range("C" & Target.Row).Value = "CP" Or Range("C" & Target.Row).Value = "NCD") And (Range("I" & Target.Row).Value = "" Or Range("I" & Target.Row).Value <= "0") Then
' Display error message to this effect
MsgBox "Error! If Mode=CP/NCD Please Enter Coupon rates before moving on"
' Disable events to prevent infinite loop
Application.EnableEvents = False
' Clear the contents of the target cell
Target.ClearContents
' Re-enable events
Application.EnableEvents = True
' Select column K of the target row
Range("I" & Target.Row).Select
End If
Dim FG As Range, t As Range, v As Variant
Dim r As Long
Set t = Target
Set FG = Range("F:G")
If Intersect(t, FG) Is Nothing Then Exit Sub
Application.EnableEvents = False
r = t.Row
v = t.Value
If v = "" Then
Range("F" & r & ":G" & r).Value = ""
End If
If IsNumeric(v) Then
If Intersect(t, Range("G:G")) Is Nothing Then
t.Offset(0, 1).Value = v / 365 * 12
Else
t.Offset(0, -1).Value = v / 12 * 365
End If
End If
Application.EnableEvents = True
End Sub