Vba boucle for
miomio51
Messages postés
15
Date d'inscription
Statut
Membre
Dernière intervention
-
miomio51 Messages postés 15 Date d'inscription Statut Membre Dernière intervention -
miomio51 Messages postés 15 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un problème pour sélectionner des cellules à l'aide d'une boucle for,
je souhaite que la cellule devienne rouge lorsque la valeur est inférieur à une autre cellule.
Quand je fais la boucle if cellule par cellule, ça marche, mais quand je souhaite faire une selection de plusieurs cellule avec une boucle for, ça ne marche plus.
Je ne sais jamais quoi utilisé entre Range et Cells, j'ai cru comprendre qu'avec la boucle for il fallait Cells mais ca ne marche pas.
les trois premiers marche mais la boucle for non, voici ce que ça donne
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E5") < Range("D5") Then
Range("E5").Interior.ColorIndex = 3
Else: Range("E5").Interior.ColorIndex = 4
End If
If Range("E6") < Range("D6") Then
Range("E6").Interior.ColorIndex = 4
Else: Range("E6").Interior.ColorIndex = 3
End If
If Range("E7") < Range("D7") Then
Range("E7").Interior.ColorIndex = 3
Else: Range("E7").Interior.ColorIndex = 4
End If
For i = 16 To 24
Next
If Cells(6, i).Value > Cells(4, i).Value Then
Cells(6, i).Interior.ColorIndex = 4
Else: Cells(6, i).Interior.ColorIndex = 3
End If
End Sub
Merci
j'ai un problème pour sélectionner des cellules à l'aide d'une boucle for,
je souhaite que la cellule devienne rouge lorsque la valeur est inférieur à une autre cellule.
Quand je fais la boucle if cellule par cellule, ça marche, mais quand je souhaite faire une selection de plusieurs cellule avec une boucle for, ça ne marche plus.
Je ne sais jamais quoi utilisé entre Range et Cells, j'ai cru comprendre qu'avec la boucle for il fallait Cells mais ca ne marche pas.
les trois premiers marche mais la boucle for non, voici ce que ça donne
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E5") < Range("D5") Then
Range("E5").Interior.ColorIndex = 3
Else: Range("E5").Interior.ColorIndex = 4
End If
If Range("E6") < Range("D6") Then
Range("E6").Interior.ColorIndex = 4
Else: Range("E6").Interior.ColorIndex = 3
End If
If Range("E7") < Range("D7") Then
Range("E7").Interior.ColorIndex = 3
Else: Range("E7").Interior.ColorIndex = 4
End If
For i = 16 To 24
Next
If Cells(6, i).Value > Cells(4, i).Value Then
Cells(6, i).Interior.ColorIndex = 4
Else: Cells(6, i).Interior.ColorIndex = 3
End If
End Sub
Merci
A voir également:
- Vba boucle for
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Idm for mac - Télécharger - Téléchargement & Transfert
- Copytrans heic for windows - Télécharger - Visionnage & Diaporama
- Instagram for pc - Télécharger - Divers Communication
- Microsoft store download for pc - Guide
For i = 16 To 24
Next
If i = valeur then
//rien faire
else
faire le code normal
merci :)