- Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
Application.EnableEvents = False
Cells(2, 10).Value = "U" 'updates balance and exposure
If Cells(2, 5).Value = "In Play" And Cells(2, 6).Value = "Suspended" And Cells(2, 17).Value <> -1 Then
Cells(2, 17).Value = -1
Else
Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"
End If
End If
Application.EnableEvents = True
However, this cyles forward 2 races and not just 1?
So I thought ok, clear out the Inplay and suspended cells to avoid re-trigger using
- Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
Application.EnableEvents = False
Cells(2, 10).Value = "U" 'updates balance and exposure
If Cells(2, 5).Value = "In Play" And Cells(2, 6).Value = "Suspended" And Cells(2, 17).Value <> -1 Then
Cells(2, 17).Value = -1
Cells(2, 5).Value = ""
Cells(2, 6).Value = ""
Else
Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"
End If
End If
Application.EnableEvents = True
End Sub
But this does the same. Can anyone see why this is?
Thanks,
Os