[résolu] boucle sur mise en forme conditionnel

Profane

XLDnaute Occasionnel
bonjour a tous
j aimerai faire une boucle sur une mise en forme conditionnel de facon macro
au lieu de repeter les lignes suivantes du range E6:J6 à E17:J17 à la mano :)
une idée ?
Ps pas trouvé comment mettre le code de facon plus visible
@+

Sub Macro1()
'1ere ligne
Range("E6:J6").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=$D$6"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
'2eme ligne
Range("E7:J7").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=$D$7"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
'3eme ligne
Range("E8:J8").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=$D$8"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
 
Dernière édition:

Paritec

XLDnaute Barbatruc
Re : boucle sur mise en forme conditionnel

Bonjour Profane le forum
après plus de 130 post tu ne sais toujours pas utiliser les balises de code???
de plus si tu nous passes ton fichier et les explications de ce que tu veux dedans on va te le faire
a+
papou:eek:
 

pierrejean

XLDnaute Barbatruc
Re : boucle sur mise en forme conditionnel

Bonjour Profane

a essayer:

Code:
Sub test()
For n = 6 To 8
Range("E" & n & ":J" & n).Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=$D$" & n
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next n
End Sub

Edit: Salut Papou
 

Profane

XLDnaute Occasionnel
Re : boucle sur mise en forme conditionnel

Bonjour Papou et Pierrejean
en fait je joins toujours des fichiers exemple donc jamais vu ou presque :)
merci Pierrejean pour ton bout de code, mais on ne traite ainsi qu'une seule ligne
et le code doit traiter de la ligne 6 à 17...j avoue que je bloque et je suis sur que cela doit être simple, comme d hab :)
 

Profane

XLDnaute Occasionnel
Re : boucle sur mise en forme conditionnel

euh désolé pierrejean
j ai lu un peu vite
j ai juste a changer
"For n = 6 To 8"
Range("E" & n & ":J" & n).Select
par
"For n = 6 To 17"
Range("E" & n & ":J" & n).Select
a force je ne vois plus rien lol
bonne journee
 

Statistiques des forums

Discussions
312 252
Messages
2 086 631
Membres
103 281
dernier inscrit
TOUFIK82