Option Explicit
Private Induit As Boolean
Private Sub SpinButton1_Change(): If Induit Then Exit Sub
Ajuster Me.[B1].Value - SpinButton1.Value, SpinButton2, SpinButton3
End Sub
Private Sub SpinButton2_Change(): If Induit Then Exit Sub
Ajuster Me.[B1].Value - SpinButton2.Value, SpinButton1, SpinButton3
End Sub
Private Sub SpinButton3_Change(): If Induit Then Exit Sub
Ajuster Me.[B1].Value - SpinButton3.Value, SpinButton1, SpinButton2
End Sub
Sub Ajuster(TotMax As Currency, ByVal SB1 As MSForms.SpinButton, ByVal SB2 As MSForms.SpinButton)
Dim TotAct As Currency
If Induit Then Exit Sub
TotAct = SB1.Value + SB2.Value: If TotAct <= TotMax Then Exit Sub
Induit = True
If SB1.Value > 0 Then SB1.Value = SB1.Value - 100
If SB2.Value > 0 Then SB2.Value = SB2.Value - 100
Induit = False
End Sub
Private Sub SpinButton1_Change()
If SpinButton1 + SpinButton2 + SpinButton3 > [B1] Then SpinButton1 = [B1] - SpinButton2 - SpinButton3
End Sub
Private Sub SpinButton2_Change()
If SpinButton1 + SpinButton2 + SpinButton3 > [B1] Then SpinButton2 = [B1] - SpinButton1 - SpinButton3
End Sub
Private Sub SpinButton3_Change()
If SpinButton1 + SpinButton2 + SpinButton3 > [B1] Then SpinButton3 = [B1] - SpinButton1 - SpinButton2
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [b3]) Is Nothing Then SpinButton1 = [b3]
If Not Intersect(Target, [b4]) Is Nothing Then SpinButton2 = [b4]
If Not Intersect(Target, [b5]) Is Nothing Then SpinButton3 = [b5]
End Sub
Private Sub S_1_Change()
If S_1 + S_2 + S_3 > [B1] Then S_1 = S_1 - 100
End Sub
Private Sub S_2_Change()
If S_1 + S_2 + S_3 > [B1] Then S_2 = S_2 - 100
End Sub
Private Sub S_3_Change()
If S_1 + S_2 + S_3 > [B1] Then S_3 = S_3 - 100
End Sub