Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, [B5:B90000]) Is Nothing Then
Range("O" & Target.Row).Formula = "=IF(MOD(RC[-13],100)=0,R[-1]C,INT(RC[-13]/100))"
ElseIf Not Intersect(Target, [F5:F90000]) Is Nothing Then
Range("S" & Target.Row).Formula = "=IF(RC[-13]=1,IF(AND(RC[-14]>=RC[-15],R[-1]C[-14]<=R[-1]C[-16],R[1]C[-14]<=R[1]C[-16]),1,IF(AND(RC[-14]<=RC[-16],R[-1]C[-14]>=R[-1]C[-15],R[1]C[-14]>=R[1]C[-15]),-1,0)),0)"