Bonjour,
Je débute dans la création de macro et j'essaie de monter une macro avec bouton qui me permettrait de passer en couleur une case en fonction de la valeur de la case du dessus.
Actuellement voici le code que j'ai pu rentrer mais j'ai encore beaucoup de colonne à faire et sur de nombreuses lignes.
J'aurai aimé savoir s'il y avait un moyen plus rapide et moins redondant d'écrire ce code.
Sub Couleur()
'Couleur colonne B
If Range("B11") > Range("B10") Then
Range("B11").Font.Color = RGB(0, 176, 80)
End If
If Range("B11") < Range("B10") Then
Range("B11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne C
If Range("C11") > Range("C10") Then
Range("C11").Font.Color = RGB(0, 176, 80)
End If
If Range("C11") < Range("C10") Then
Range("C11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne D
If Range("D11") > Range("D10") Then
Range("D11").Font.Color = RGB(0, 176, 80)
End If
If Range("D11") < Range("D10") Then
Range("D11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne I
If Range("I11") > Range("I10") Then
Range("D11").Font.Color = RGB(0, 176, 80)
End If
If Range("I11") < Range("I10") Then
Range("I11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne J
If Range("J11") > Range("J10") Then
Range("J11").Font.Color = RGB(0, 176, 80)
End If
If Range("J11") < Range("J10") Then
Range("J11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne K
If Range("K11") > Range("K10") Then
Range("K11").Font.Color = RGB(0, 176, 80)
End If
If Range("K11") < Range("K10") Then
Range("K11").Font.Color = RGB(255, 0, 0)
End If
'Couleur colonne L
If Range("L11") > Range("L10") Then
Range("L11").Font.Color = RGB(0, 176, 80)
End If
If Range("L11") < Range("L10") Then
Range("L11").Font.Color = RGB(255, 0, 0)
End If
End Sub