Finissions de boucle

  • Initiateur de la discussion Initiateur de la discussion Temjeh
  • 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 !

Temjeh

XLDnaute Accro
Bonjour et merci d'avance

Hey oui après 2 hrs d'essai je met mon orgueil de coté et solicite votre aide pour faire ma boucle:
Ceci est bon:
Code:
z = 5
For i = 6 To 8
If Cells(i, 12) = "Exclu" Then Cells(6, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 9 To 11
If Cells(i, 12) = "Exclu" Then Cells(7, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 12 To 14
If Cells(i, 12) = "Exclu" Then Cells(8, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 15 To 17
If Cells(i, 12) = "Exclu" Then Cells(9, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 18 To 20
If Cells(i, 12) = "Exclu" Then Cells(10, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 21 To 23
If Cells(i, 12) = "Exclu" Then Cells(11, z).Font.ColorIndex = 3
z = z + 2
Next i

z = 5
For i = 24 To 26
If Cells(i, 12) = "Exclu" Then Cells(12, z).Font.ColorIndex = 3
z = z + 2
Next i

Il me semble que ceci devrait fonctionné mais ca ne fait pas ce que j'aimerais:test sur colonne et si trouve met cell en rouge (ici colonne de test est la même mais les cell à mettre en rouge sont 3 par ligne et en dessous l'un de l'autre:
Ptêtre il me manque la solution pour le faire sortir de la boucle après 3 fois
[For b = 6 To 12

For i = 6 To 26
a = 1
z = 5
If Cells(i, 12) = "Exclu" Then Cells(b, z).Font.ColorIndex = 3
z = z + 2
a = a + 1
If a = 3 Then Exit For
If z > 9 Then Exit For
Next i
Next ba = 1
For b = 6 To 12
z = 5
For i = 6 To 26
If Cells(i, 12) = "Exclu" Then Cells(b, z).Font.ColorIndex = 3
z = z + 2
a = a + 1
If a = 3 Then Exit For
If z > 9 Then Exit For
Next i
Next b
[/Code]

Merci


A++
Ce lien n'existe plus
 
Dernière édition:
Re : Finissions de boucle

Bonjour le fil, Temjeh

Essayes le code suivant (si j'ai bien compris)
Code:
z = 5
For i = 6 To 26
   If Cells(i, 12) = "Exclu" Then Cells(int(i / 3) + 4, z).Font.ColorIndex = 3
   z = IIf(z < 9, z + 2, 5)
Next i
A plus
 
- 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
932
Réponses
15
Affichages
830
Réponses
4
Affichages
287
Réponses
8
Affichages
800
Réponses
2
Affichages
259
Réponses
8
Affichages
402
Retour