• Initiateur de la discussion Initiateur de la discussion maval
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

maval

XLDnaute Barbatruc
Bonsoir,

J’aimerai simplifier mon code
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For n = 3 To 50

'Point normal
If Cells(n, 4) < 162 And Cells(n, 4) > 0 Then
    If Cells(n, 4) <> 81 And Cells(n, 4) <> 91 And Cells(n, 4) <> 71 Then
            If Cells(n, 5) = 1 Then
                If 162 - Cells(n, 4) = Cells(n, 8) Then
                Cells(n, 8) = 162 - Cells(n, 4)
                Cells(n, 4) = Cells(n, 4) + 20
                End If
            Else
            Cells(n, 8) = 162 - Cells(n, 4)
            End If
    End If
End If
If Cells(n, 8) < 162 And Cells(n, 8) > 0 Then
    If Cells(n, 8) <> 81 And Cells(n, 8) <> 91 And Cells(n, 8) <> 71 Then
            If Cells(n, 9) = 1 Then
                If 162 - Cells(n, 8) = Cells(n, 4) Then
                Cells(n, 4) = 162 - Cells(n, 8)
                Cells(n, 8) = Cells(n, 8) + 20
                End If
            ElseIf Cells(n, 9) = 0 And Cells(n, 5) = 0 Then
            Cells(n, 4) = 162 - Cells(n, 8)
            End If
    End If
End If

If [H4] = 81 And [L1] <> 1 Then
[H4] = 0
[D4] = 81
[A1] = 81
[L1] = 1
ElseIf [D4] = 81 And [L1] <> 1 Then
[D4] = 0
[H4] = 81
[A1] = 81
[L1] = 1
End If
If [A1] = 81 And [D5] <> 0 And [H5] <> 0 Then
   If [D5] < [H5] Then
   [H5] = [H5] + [A1]
   [A1] = 0
   ElseIf [D5] > [H5] Then
  [D5] = [D5] + [A1]
   [A1] = 0
    End If
End If
If [H5] = 81 And [L2] <> 1 Then
[H5] = 0
[D5] = 81
[A1] = 81
[L2] = 1
ElseIf [D5] = 81 And [L2] <> 1 Then
[D5] = 0
[H5] = 81
[A1] = 81
[L2] = 1
End If
If [A1] = 81 And [D6] <> 0 And [H6] <> 0 Then
   If [D6] < [H6] Then
   [H6] = [H6] + [A1]
   [A1] = 0
   ElseIf [D6] > [H6] Then
  [D6] = [D6] + [A1]
   [A1] = 0
    End If
End If

Next

Un fichier valant mieux qu'un long discours, veuillez voir la pièce jointe.

Par avance merci pour votre aide.
Cordialement
Maval
 

Pièces jointes

- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
909
Réponses
15
Affichages
782
Réponses
4
Affichages
732
Retour